Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I suppose that the data which you receive as <code>result.colNames</code> and <code>result.colModel</code> <strong>are strings and not objects</strong>.</p> <pre><code>var cn = ['AccountID','ClientID']; var cm = [ {editable:false,index:'AccountID',jsonmap:'AccountID',key:false,name:'AccountID', resizable:true,search:false,sortable:true,width:300}, {editable:false,index:'ClientID',jsonmap:'ClientID',key:false,name:'ClientID', resizable:true,search:false,sortable:true,width:300}]; var cd = '{total:1,page:1,records:1,rows:[{AccountID:1,ClientID:3}]}'; jQuery('#QueryGrid').jqGrid({ jsonReader: { repeatitems: false }, height: 'auto', colNames: cn, colModel: cm, datastr: cd, viewrecords: true }); </code></pre> <p>By the way some properties which you use in the <code>colModel</code> parameters are default. The parameter <code>shrinkToFit: true</code> is also default. So you can reduce to</p> <pre><code>[{index:'AccountID',jsonmap:'AccountID',name:'AccountID',search:false,width:300}, {index:'ClientID',jsonmap:'ClientID',name:'ClientID',search:false,width:300}] </code></pre> <p>If you will use <code>jsonReader: { repeatitems: false, cell:"" }</code> then it can be more shorter</p> <pre><code>[{index:'AccountID',name:'AccountID',search:false,width:300}, {index:'ClientID',name:'ClientID',search:false,width:300}] </code></pre> <p>Probably what you really wanted is to send the <code>result.colNames</code> and <code>result.colModel</code> as a JSON strings which can be converted to objects for example withj respect of <a href="http://api.jquery.com/jQuery.parseJSON/" rel="nofollow">jQuery.parseJSON</a>. In the case you should change a little the format of the data in the <code>result.colNames</code> and <code>result.colModel</code>. Following code will also work</p> <pre><code>var cnStr = '["AccountID","ClientID"]'; var cmStr = '[{"index":"AccountID","name":"AccountID","search":false,"width":300},{"index":"ClientID","name":"ClientID","search":false,"width":300}]'; var cd = '{total:1,page:1,records:1,rows:[{AccountID:1,ClientID:3}]}'; jQuery('#QueryGrid').jqGrid({ jsonReader: { repeatitems: false, cell:"" }, datatype: 'jsonstring', height:'auto', colNames: jQuery.parseJSON(cnStr), colModel: jQuery.parseJSON(cmStr), datastr: cd, viewrecords: true }); </code></pre> <p>One more small remark. You don't use <code>key:true</code> or <code>id</code> values in the jqGrid data. It is potentially dangerous. You should understend that jqGrid use id="1", id="2" and so on if no <code>id</code> exist in the data. The problem can be if you use two or more such grids on one page. You can receive <strong>double ids</strong> very easy which is not allowed.</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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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