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. enter image description here

$("#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:

enter image description here

  • This is the data we receive when opening the "Parent" JSON Tree - diJey
  • Thanks to Oleg for help. The solution can be seen here -> http://stackoverflow.com - diJey
  • Please use one account. The previous question is frozen and it is still not “accepted”. - Oleg
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

I have a suspicion that you are using a TreeGrid is not quite in the right situation, because The first six columns in the leafs are always empty. In addition, the use of two different url vidyadit strange. It is possible that the subgrid would be more suitable. At the same time, the main grid would not be editable, and the subgrid would be the opposite, editable. the main grid would have one url, the subgrid would have another. It seems to me that the two would be simpler and clearer. In any case, the following parameters can be safely removed.

 treedatatype:"json", treeReader:{ level_field: "level", parent_id_field: "parent", leaf_field: "isLeaf", expanded_field: "expanded", loaded:true, }, editable: true, gridview: true, caption: '', rownumbers: true 

I would recommend deleting the following columns.

 { label: 'id', name: 'id', key: true,hidden: true}, { label: 'idTovar', name: 'idTovar',hidden: true}, 

and use, instead,

 additionalProperties: ['id', 'idTovar'] 

In this case, the 'id' and 'idTovar' fields of the source data would be read locally and getLocalRow and the data parameter would contain these fields, but in the DOM the table would have nothing superfluous.

As for your main question, the answer but I already wrote here earlier.