Created
August 23, 2013 05:01
-
-
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
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
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