Last active
August 21, 2020 15:43
-
-
Save gnutix/03426bc4beda87a4126787373795b980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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