javascript - Jqgrid subgrid json data not showing -
the main grid loads info fine, subgrid info not displayed.
this json info returned java controller subgrid:
{"alltrackingnrs":null,"page":1, "records":[{"reference":"dgl1008","shipunittype":"carton","totalofcartons":1,"trackingnr":"slc160759060"},{"reference":"dgl-1008","shipunittype":"carton","totalofcartons":1,"trackingnr":"slc160759060"},{"reference":"dgl-1008","shipunittype":"carton","totalofcartons":1,"trackingnr":"slc160759060"},{"reference":"dgl1008","shipunittype":"carton","totalofcartons":1,"trackingnr":"slc160759060"}], "recordstotal":4,"rows":4,"sidx":null,"sord":"asc","total":1,"trackingnr":"slc160759060","truckid":null,"truckshipmentcomponent":{}}
this javascript code
<script type="text/javascript"> jquery().ready(function () { var grid = jquery("#shipment_grid"); var maingridprefix = "s_"; grid.jqgrid({ url: '${pagecontext.request.contextpath}/gettruckshipmentjsonaction?truckid=' + <c:out value="${truckid}" />, datatype: "json", mtype: 'get', colnames: ['lead tracking #'], colmodel: [ {name: 'trackingnr', width: 100} ], rownum: 10, height: "auto", width: 850, idprefix: maingridprefix, autoheight: true, rowlist: [10, 20, 30], pager: jquery('#shipment_grid_pager'), sortname: 'trackingnr', emptyrecords: 'no shipments found selected filter(s)', sortorder: "desc", jsonreader: { root: "records", page: "page", total: "total", records: "rows", repeatitems: false }, viewrecords: true, altrows: false, gridview: true, multiselect:true, hidegrid: false, shrinktofit: true, forcefit: true, idprefix: maingridprefix, caption: "shipments overview", subgrid: true, loadcomplete: function(data) { grid.jqgrid('setcolprop', 'trackingnr',{ searchoptions: { clearsearch: true, attr: {style: "align:'left'; width:150px;margin-top:1px;"}, sopt:['cn'], datainit: function(elem) { $(elem).autocomplete({ source:data.alltrackingnrs, delay:0, minlength:2 }); } } }); grid.jqgrid('filtertoolbar', {autosearch: true}); // cut down font size of autocomplete input $(".ui-autocomplete.ui-widget").css({fontsize: "11px"}); }, subgridrowexpanded: function (subgriddivid, rowid) { var rowdata = grid.getrowdata(rowid); var seltrackingnr= rowdata['trackingnr']; var $subgrid = $("<table id='" + subgriddivid + "_t'></table>"); // purerowid = $.jgrid.strippref(maingridprefix, rowid), // subgrids = $(this).jqgrid("getgridparam", "userdata"); $subgrid.appendto("#" + $.jgrid.jqid(subgriddivid)); $subgrid.jqgrid({ data: "json", mtype: 'get', url: '${pagecontext.request.contextpath}/gettruckshipmentjsonaction?trackingnr=' + seltrackingnr, colnames: ['ship type (pallet / carton)', 'ship unit (pallet id / cone #)', 'total cartons'], colmodel: [ { name: "shipunittype"}, { name: "reference", sorttype: "integer" }, { name: "totalofcartons", sorttype: "integer" } ], cmtemplate: { align: "center" }, jsonreader: { root: "records", repeatitems: false }, sortname: "reference", sortorder: "desc", height: "100%", rownum: 10, autowidth: true, autoencode: true, gridview: true, idprefix: rowid + "_" }); } }).navgrid('#shipment_grid_pager', {edit: false, add: false, del: false, search: false, refresh: true}) .jqgrid("setlabel", "trackingnr", "", {"text-align": "left"}); //align 'lead tracking #' column header left; }); </script>
how can subgrid info displayed?
i have fixed problem, typo error. wrote data: "json", instead of datatype: "json" in subgridrowexpanded: function (subgriddivid, rowid) {....} function
javascript json jqgrid subgrid
No comments:
Post a Comment