Forum
November 2nd, 2014
A
A
A
Topic RSS
Related Topics
Offline
The forums are currently locked and only available for read only access



Subgrid data not loading
Tags: subgrid
15/03/2013
16:37
16:37

olefrank
New Member
Members
Forum Posts: 2
Member Since:
14/03/2013
14/03/2013

I'm new to JqGrid. I'm trying to make a grid with products. For each product I want a subgrid showing orders.
I can't load data in the subgrids. The 'load_sub_data_json.php' is never loaded...
Here's the JS my HTML file:
<pre> jQuery(document).ready(function() { $("#list").jqGrid({ height: 'auto', blockui: true, altRows: true, loadonce: true, url:'load_main_data_json.php', datatype: 'json', mtype: 'GET', colNames:['ProductCode','ProductName', 'ProductVendor'], colModel :[ {name:'productcode', index:'productcode', width:100, align:'right'}, {name:'productname', index:'productname', width:280, align:'right'}, {name:'productvendor', index:'productvendor', width:200, align:'right'} ], rowNum:35, rowList:[25,50,75,100,125,150,175,200], sortname: 'productcode', sortorder: 'desc', viewrecords: true, caption: 'My first grid', subGrid: true, subGridUrl: 'load_sub_data_json.php', subGridModel: [ { name : ['Order number','Order date','Shipped date','Comments'], index : ['orderNumber', 'orderDate', 'shippedDate', 'comments'], width : [55,100,100,200], align : ['right','right','right','right'], params: ['productcode'] } ] }); }); </pre>
And this is my php-file loading data to the subgrid:
<pre> include("dbconfig.php"); $id = $_REQUEST['id']; $productCode = $_REQUEST['productcode']; // param passed by query // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); // select database mysql_select_db($database) or die("Error conecting to db."); // select columns $SQL = "select o.orderNumber, o.orderDate, o.shippedDate, o.comments from orderdetails d inner join orders o on o.orderNumber = d.orderNumber where d.productcode='" . $id. "';"; $result = mysql_query( $SQL ) or die("CouldnÂ’t execute query.".mysql_error()); $response = new stdClass; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $response->rows[$i]['id']=$row['orderNumber']; $response->rows[$i] ['cell']=array($row['orderNumber'],$row['orderDate'],$row['shippedDate'],$row['comments']); $i++; } echo json_encode($response); </pre>
Forum Timezone: Europe/Sofia
Most Users Ever Online: 715
Currently Online:
66 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66