Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One can see at least two important problem in the code of <code>abc</code> function.</p> <p>The first one is the usage of <code>setGridParam</code> <em>before</em> <code>JQuery("#table2").jqGrid({...});</code> which <em>creates</em> the grid. You can't use <code>setGridParam</code> on the <code>&lt;table&gt;</code>. The call like <code>JQuery("#table2").jqGrid({...});</code> converts empty <code>&lt;table id="table2"&gt;&lt;/table&gt;</code> element in relatively complex structure of dives and tables which will be used to display the grid. So you should <em>first create the grid</em> (covert empty <code>&lt;table&gt;</code> to the grid) and only after it you can use <code>setGridParam</code> or <code>.trigger("reloadGrid")</code> to refresh grid content.</p> <p>The second problem is the usage of <code>JQuery("#table2").jqGrid({...});</code> inside of function <code>abc</code> which you call <em>multiple times</em>. As I described before the call <code>JQuery("#table2").jqGrid({...});</code> coverts empty <code>&lt;table&gt;</code> to the grid. So one can make such call <em>only once</em>. For the second loading of the grid you should just use <code>setGridParam</code> and <code>.trigger("reloadGrid")</code> to refresh grid content.</p> <p><strong>UPDATED</strong>: If you want implement master/details scenario you can do following:</p> <pre><code>// create master grid $("#table1").jqGrid({ datatype: "json", url: "masterGridUrl", onSelectRow: function (rowid, state) { if (state) { // if not the same row was previously selected // refresh detail grid $("#table2").jqGrid("setGridParam", { datatype: "json"}) .trigger("reloadGrid", [{page: 1}]); } }, ... // another options }); // create details grid without filling the data initially $("#table2").jqGrid({ datatype: "json", // we use "local" instead of "json" to have to request to the server url: "JGridA", postData: { action: "abc", hidden: function () { // id of currently selected row return $("#table1").jqGrid("getGridParam", "selrow"); } }, ... // other options }); </code></pre> <p>It will create master grid "#table1" and empty detail grid "#table2". After selection of row in the master grid the body of detail grid will be reloaded. Detail grid send to the server two additional parameters: one static parameter <code>action=abc</code> and another parameter <code>hidden</code> which value is the rowid of the master grid.</p> <p>If you use <code>navGrid</code> in the master grid you can add <code>beforeRefresh</code> callback (see <a href="https://stackoverflow.com/a/3772720/315935">the answer</a> for the code example). In the <code>beforeRefresh</code> callback of master grid you can call <code>clearGridData</code> for the detail grid. So if you would refresh the master grid the detail grid will be empty till the row in the master grid will be selected.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload