Skip to content

Instantly share code, notes, and snippets.

@gnutix
Last active August 21, 2020 15:43
Show Gist options
  • Save gnutix/03426bc4beda87a4126787373795b980 to your computer and use it in GitHub Desktop.
Save gnutix/03426bc4beda87a4126787373795b980 to your computer and use it in GitHub Desktop.
function isNotEmpty(value) {
return value !== undefined && value !== null && value !== "";
}
$(function() {
var customDataSource = new DevExpress.data.CustomStore({
key: "ID",
load: function(loadOptions) {
var d = $.Deferred();
var params = {};
[
"filter",
"group",
"groupSummary",
"parentIds",
"requireGroupCount",
"requireTotalCount",
"searchExpr",
"searchOperation",
"searchValue",
"select",
"sort",
"skip",
"take",
"totalSummary",
"userData"
].forEach(function(i) {
if(i in loadOptions && isNotEmpty(loadOptions[i])) {
params[i] = JSON.stringify(loadOptions[i]);
}
});
$.getJSON('my/route/endpoint', params)
.done(function(response) {
d.resolve(response.data, {
totalCount: response.totalCount,
summary: response.summary,
groupCount: response.groupCount
});
})
.fail(function() { throw "Data loading error" });
return d.promise();
},
});
$("#gridContainer").dxDataGrid({
dataSource: customDataSource,
remoteOperations: { groupPaging: true }
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment