Forum
01:38
26/01/2009
I have the following piece of code to create a jqGrid with subgrid. I see jqGrid is hanging when the subgrid row is expanded and parent colmn headers are clicked to sort the parent grid. Could anybody please tell me if there's any problem with my code.
$(document).ready(function() {
var mystr = “<?xml version='1.0' encoding='utf-8'?>”;
mystr += “<invoices>”;
mystr += “<rows>”;
mystr += “<row>”;
mystr += “<cell>32998</cell>”;
mystr += “<cell>12/03/2008</cell>”;
mystr += “<cell>29</cell>”;
mystr += “<cell>3.72</cell>”;
mystr += “<cell>32.72</cell>”;
mystr += “<cell>Call when ready</cell>”;
mystr += “</row>”;
mystr += “<row>”;
mystr += “<cell>23998</cell>”;
mystr += “<cell>12/13/2008</cell>”;
mystr += “<cell>51.10</cell>”;
mystr += “<cell>13.72</cell>”;
mystr += “<cell>64.82</cell>”;
mystr += “<cell>Special Order</cell>”;
mystr += “</row>”;
mystr += “</rows>”;
mystr += “</invoices>”;
var childStr = [];
childStr[0] = "<?xml version='1.0' encoding='utf-8'?>";
childStr[0] += "<items>";
childStr[0] += "<rows>";
childStr[0] += "<row>";
childStr[0] += "<cell>Pizza</cell>";
childStr[0] += "<cell>2</cell>";
childStr[0] += "<cell>14.50</cell>";
childStr[0] += "</row>";
childStr[0] += "<row>";
childStr[0] += "<cell>Ghirardelli Chocolette</cell>";
childStr[0] += "<cell>2</cell>";
childStr[0] += "<cell>14.50</cell>";
childStr[0] += "</row>";
childStr[0] += "</rows>";
childStr[0] += "</items>";
childStr[1] = "<?xml version='1.0' encoding='utf-8'?>";
childStr[1] += "<items>";
childStr[1] += "<rows>";
childStr[1] += "<row>";
childStr[1] += "<cell>Pasta</cell>";
childStr[1] += "<cell>1</cell>";
childStr[1] += "<cell>10.40</cell>";
childStr[1] += "</row>";
childStr[1] += "<row>";
childStr[1] += "<cell>Biriyani</cell>";
childStr[1] += "<cell>3</cell>";
childStr[1] += "<cell>40.70</cell>";
childStr[1] += "</row>";
childStr[1] += "</rows>";
childStr[1] += "</items>";
jQuery(”#list”).jqGrid({
datatype: 'xmlstring',
datastr : mystr,
colNames:['Inv No','Date', 'Amount','Tax','Total','Notes'],
colModel :[
{name:'invid', index:'invid', width:55, sorttype:'int'},
{name:'invdate', index:'invdate', width:90, sorttype:'date',
datefmt:'Y-m-d'},
{name:'amount', index:'amount', width:80, align:'right',
sorttype:'float'},
{name:'tax', index:'tax', width:80, align:'right', sorttype:'float'},
{name:'total', index:'total', width:80, align:'right', sorttype:'float'},
{name:'note', index:'note', width:150, sortable:false} ],
pager: jQuery('#pager'),
rowNum:10,
viewrecords: true,
imgpath: '/jquery/plugins/jqgrid/themes/basic/images',
caption: 'Table Grid from XML String',
width:900,
height:350,
subGrid: true,
subGridRowColapsed: function(subgrid_id, row_id) {},
subGridRowExpanded: function(subgrid_id, row_id) {
var subgrid_table_id;
subgrid_table_id = subgrid_id+”_t”;
//alert(row_id);
jQuery(”#”+subgrid_id).html(”<table id='”+subgrid_table_id+”' class='scroll'></table>”);
jQuery(”#”+subgrid_table_id).jqGrid({
datatype: 'xmlstring',
datastr : childStr[row_id-1],
colNames:['Item','Quantity', 'Price'],
colModel :[
{name:'itemid', index:'itemid', width:50, sorttype:'text'},
{name:'qtyid', index:'qtyid', width:50, sorttype:'int'},
{name:'priceid', index:'priceid', width:50, align:'left',
sorttype:'float'},
],
width: 500,
height:100
}) //end of child grid
} //end of subgridrowexpanded
}); //end of parent grid
}); //end of document ready
</script>
09:22
Moderators
30/10/2007
Hello,
Currently subgrid does not accept xmlstring and jsonstring parameters.
I will try to correct this in final 3.4 release
Thank you
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
05:46
Moderators
30/10/2007
Hello,
Sorry, I do not have look into the code deeper. It should work, but you should care in you case about the following:
The expression:
datastr : childStr[row_id-1]
Can not be evalueted good - I think the better way will be:
datastr : childStr[parseInt(row_id,10)-1],
The reason for this is the row_id is interpreted as string and not as number.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
53 Guest(s)
Currently Browsing this Page:
1 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