jquery - jqGrid does not refresh with new data -
i getting json data server passing in page number n should nth 100 rows. after loading once, , pressing "next page" button, seems new data correctly (i output first object in new data when being refreshed) not populate data in grid.
<div> <button id="refreshjobsbutton">refresh jobs</button> <button id="nextpagejobsbutton">next page</button> <table id="jobtable"><tr><td/></tr></table> <div id="jobpager" class="ui-widget"></div> </div>
$(document).ready(function() { var page = 0; $('#nextpagejobsbutton').button({ icons: { primary: "ui-icon ui-icon-arrowrefresh-1-s" } }).click(function(){ page = page + 1; $("#jobtable").jqgrid('gridunload'); refreshjob(page); }); }; function refreshjob(page) { var $source = "ajax/refreshjob?page=" + page; $.ajax({ url: $source, datatype: "json", success: populatejobs, error: handleajaxerror }); } function populatejobs(jobs) { k = object.keys(jobs)[0]; l = object.keys(jobs[k])[0]; alert ("first job in list " + jobs[k][l]); //outputs correct job of page $(function() { var grid = $('#jobtable'); $('#jobtable').jqgrid({ datatype: 'jsonstring', editurl: 'ajax/modifyjob', mtype: 'post', loadonce: false, datastr: jobs, height: 600, autowidth: true, forcefit: true, gridview: true, viewrecords: true, multiselect: true, sortable: false, toppager: true, treegrid: true, treegridmodel: 'adjacency', treedatatype: 'post', expandcolumn: 'job', expandcolclick: true, colnames: [ "id (hidden)", "job type (hidden)" ], colmodel: [{ name: 'id', index: 'id', editable: true, edittype: 'text', key: true }, { name: 'jobtype', index: 'jobtype', editable: true, edittype: 'text' }], jsonreader: { repeatitems: false, root: function(obj) { return obj; }, page: function() { return 1; }, total: function() { return 1; }, records: function(obj) { return obj.length; } } });
can advise wrong?
search $(function() {
in code. it's same $(document).ready(function() {
, have included block $(function() {
inside of $(document).ready(function() {
. should remove $(function() {
(see near place creates jqgrid).
Comments
Post a Comment