Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In order to use json data as a response from a query the response has to be formatted correctly. It is difficult to determine what is the correct response and how to get it from the documents. More problems can occur as a result of your server settings generating a warning as part of the response which will cause the grid not to load. </p> <p>From the documents this is the default json reader, meaning if you format your response correctly you don't need to add anything / a custom json reader. </p> <pre><code>jsonReader : { root: "rows", page: "page", total: "total", records: "records", repeatitems: true, cell: "cell", id: "id", userdata: "userdata", subgrid: { root:"rows", repeatitems: true, cell:"cell" } </code></pre> <p>First make sure you have the right response format. <code>{"page":1,"total":1,"records":"2","rows":[{"id":"1","cell":["1","mydata1"]},{"id":"2","cell":["2","mydata2"]}]}</code></p> <p>No sample is given on the docs page but the above is correct if you only have two columns in your grid. You need to get your server query / parsing of your server query and values passed to the page that runs your sever side scripts to return this format. The example.php page from the documents gives you all the values you need. </p> <p>This code will give you the proper header, to avoid error warnings and matches up with the response from above. Also note that in the docs they do not add the apostrophes around the indexes for the associative array index names. That will fail. </p> <pre><code>header('Content-type: application/json');$responce = new stdClass();$responce-&gt;page = $page;$responce-&gt;total = $total_pages;$responce-&gt;records = $count;$i=0;while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {$responce-&gt;rows[$i]['id']=$row['ID'];$responce-&gt;rows[$i]['cell']=array($row['ID'],$row['entity_name']); $i++; } echo json_encode($responce); </code></pre> <p>To rehash what is missing in the docs (it is possible that I just missed them and even if, the documents for jQgrid are epic/a masters work): 1. No mention of the need for a header statement for json (it is clear with the XML examples) 2. No sample of what a working returned string should look like 3. Lack of proper formatting of the associative array indexes. 4. No mention of how to avoid a PHP warning being returned as part of the response</p>
    singulars
    1. This table or related slice is empty.
    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. 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