Forum


04:06

17/11/2008

Hi all,
Does anybody know whats wrong with the snippet below, I;m working with XMLstring , I copied the sample from the jqgriddocs.pdf and it works fine. But when I rename the <rows> , <row> or <cell> it stops working.
I already specified the root, row, and xmlmap but to no avail.
it seems only the default datastructure is the only one that works.
<rows><row><cell></cell></row></rows>
please see code snippet below:
<script type="text/javascript">
var mystr = "<?xml version='1.0' encoding='utf-8'?> <myroot> <myrow> <column1>data1</column1> <column2>data2</column2> </myrow> </myroot> ";
jQuery(document).ready(function() {
jQuery("#list").jqGrid({
root: "myroot",
datatype: 'xmlstring',
datastr: mystr,
colNames: ['Inv No', 'Date'],
colModel: [
{ name: 'invid', index: 'invid', width: 55, xmlmap: "column1" },
{ name: 'invdate', index: 'invdate', width: 90, xmlmap: "column2"}],
pager: jQuery('#pager'),
rowNum: 10,
viewrecords: true, repeatitems: false,
imgpath: 'themes/basic/images',
caption: 'My first grid'
});
});
</script>
04:13

17/11/2008

GOT IT!
Ah, forgive the newbie, I got it. just after posting the question.
the correct snippet is below, check the maroon colored text.
var mystr = "<?xml version='1.0' encoding='utf-8'?> <myroot> <myrow> <column1>data1</column1> <column2>data2</column2> </myrow> </myroot> ";
jQuery(document).ready(function() {
jQuery("#list").jqGrid({
datatype: 'xmlstring',
datastr: mystr,
colNames: ['Inv No', 'Date'],
colModel: [
{ name: 'invid', index: 'invid', width: 55, xmlmap: "column1" },
{ name: 'invdate', index: 'invdate', width: 90, xmlmap: "column2"}],
pager: jQuery('#pager'),
rowNum: 10,
viewrecords: true, repeatitems: false,
imgpath: 'themes/basic/images',
caption: 'My first grid',
loadonce: true,
xmlReader: { root : "myroot", row: "myrow", repeatitems: false}
});
});
Most Users Ever Online: 715
Currently Online:
47 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