Skip to content

Instantly share code, notes, and snippets.

@xcooper
Created August 23, 2013 05:01
Show Gist options
  • Save xcooper/6315701 to your computer and use it in GitHub Desktop.
Save xcooper/6315701 to your computer and use it in GitHub Desktop.
new this function to 'datatype' of jqgrid options, this will sync between Backbone collection and jqGrid
var BackboneJqGridReader = function(colleciton, grid) {
return function(postdata) {
var submitData = _.extend({}, postdata);
Backbone.sync("read", colleciton, {
attrs: submitData,
cache: false,
contentType: "application/json",
processData: false,
type: "POST",
success: function(data) {
colleciton.reset(data.gridModel);
grid.setGridParam({
lastpage: data.total,
page: data.page,
records: data.records
});
grid.each(function() {
if (this.grid) this.updatepager();
});
}
});
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment