Here is my code for remote dataModel
var rowTemplate = {};
var dataModel= {
dataType: "JSON",
location: "remote",
paging: "remote",
sorting: "remote",
recIndx: "id",
sortIndx: "id",
sortDir: "down",
colIndx:"id",
url: "get_grid_data?id=1",
getData: function (response) {
if(response.status=='success'){
var grid_data=response.datas;
var jsonobj = jQuery.parseJSON(grid_data[0].input_json);
jsonobj.forEach(function(item, indx) {
colModel.push({
dataIndx: item.name,
title: item.label
});
(function(_indx) {
Object.defineProperty(rowTemplate, item.name, {
enumerable: true,
// configurable:true,
get() {
return this.jsonobj[_indx].userData;
},
set(val) {
this.jsonobj[_indx].userData = val;
}
})
})(indx);
});
return {curPage: response.page_number, totalRecords: response.total_rows, data: grid_data };
}else{
swal(response.message);
}
}
};