I load the initial data from the server. But the treeGrid data is loaded from the server only at the moment of opening the "tree". As a result, when editing an Edit Form, I want to go over all the records except for 'Parent'. I edit only the Leaf data ! In fact, there is a lot of data, and in which nothing will be revealed. But on the screen for clarity, I made one "parent" open.
$("#bound").jqGrid({ dataType : 'JSON', url: '/moderateStock/getBound.php', mtype: 'POST', editurl: '/editData.php', serializeEditData: function (postData) { postData.table = 'bound'; return postData; }, beforeRequest: function (){ if(!!this.p.postData.nodeid) { this.p.url = '/moderateStock/getTreeBound.php'; } else{ this.p.url = '/moderateStock/getBound.php'; } }, loadComplete: function () { var $this = $(this); $("tr.jqgrow", $this).contextMenu('myMenuBound', { bindings: { 'cm_boundEdit': function(trigger) { rowid = trigger.id; $this.typeEditView = 'cm_tm_table'; $this.jqGrid("editGridRow", trigger.id, { recreateForm: true, width: 1000, height: "auto"}); } }, onContextMenu: function(event, menu) { var rowId = $(event.target).closest("tr.jqgrow").attr("id"), m = $this[0].p, data = m.data[m._index[rowId]], i, lastSelId; i = $.inArray(rowId, m.selarrrow); if (m.selrow !== rowId && i < 0) { $this.jqGrid('setSelection', rowId); } return true; }, formEditing: { closeOnEscape: true, closeAfterEdit: false, savekey: [false, 13], height: "auto", beforeShowForm: function ($form) { // on Edit if($(this)[0].typeEditView){ var html_grid = '<div id="jqGridSubgridBoundWrapper" style="overflow: hidden"><table id="bound"></table><div id="bound_subgridPager"></div></div>'; $(html_grid).insertBefore($('#FrmGrid_Bound', form)); } }}}) }, colModel: [ { label: 'id', name: 'id', key: true,hidden: true}, { label: 'idTovar', name: 'idTovar',hidden: true}, { label: 'Группа',name: 'category'}, { label: 'Наименование', name: 'idPreparat',editable:true }, ], iconSet: "fontAwesome", treeGrid:true, ExpandColumn:'category', treedatatype:"json", treeGridModel:"adjacency", treeReader:{ level_field: "level", parent_id_field: "parent", leaf_field: "isLeaf", expanded_field: "expanded", loaded:true, }, editable: true, gridview: true, caption: '', rownumbers: true }).jqGrid('filterToolbar',{searchOnEnter: false, searchOperators: true,stringResult:true,defaultSearch: 'cn'}); });
Data from the server: