Featured post
jquery - jqgrid - refresh a grid after an ajax file upload -
how refresh jqgrid based grid outside of grid itself? within code grid exists option call reloadgrid
. however, want reload grid after doing ajax file upload, outside of jqgrid code. how call reloadgrid
in context?
i realize can reload entire page like: location.reload();
reloads whole lot , puts me first page of results grid , kind of defeats purpose of using ajax upload file in first place.
some code:
reloadgrid called within jqgrid follows:
$("#thegrid").trigger("reloadgrid");
but nothing when called within ajaxupload:
oncomplete: function(file, response) { if (response == 'success') { //location.reload(); $("#thegrid").trigger("reloadgrid"); }else if (response == 'error') { alert("doh!"); }
if uncomment location.reload()
, page reloads trigger uncommented (as in above example) nothing happens @ all. how reload grid?
i see no problem in using of $("#thegrid").trigger("reloadgrid")
outside of jqgrid. problem in relation between oncomplete
ajaxupload
, $("#thegrid")
@ all.
for example can define external button on same page jqgrid <table>
element having id="thegrid" , use
$("#button").click(function() { if ($("#thegrid").length === 0) { alert("no element id='thegrid' found"); } if ($.isfunction($("#thegrid").jqgrid) !== true) { alert("$('#thegrid') not jqgrid"); } var e = $("#thegrid").data("events"); if (typeof(e) !== "undefined" && typeof(e.reloadgrid) !== "undefined") { $("#thegrid").trigger("reloadgrid"); } else { alert("$('#thegrid') not bound 'reloadgrid' function"); } }
you see the code work without alerts. can include same code inside of oncomplete
handler of ajaxupload.
to verify 'reloadgrid' function work can use loadcomplete:
loadcomplete: function() { alert("grid loaded/reloaded"); }
updated: starting jquery 1.8 1 should use $._data($("#thegrid")[0], "events");
instead of $("#thegrid").data("events")
list of events of grid.
- Get link
- X
- Other Apps
Comments
Post a Comment