1

I have the code as follows:

    $(function () {                 
        jQuery("#list48").jqGrid({
            datatype: "xml",
            url: 'server.java',     
            mtype: "POST",
            colNames:['Inv No','Date'],
            colModel:[
                {name:'id',index:'id', width:60,},
                {name:'invdate',index:'invdate', width:90}                  
            ],
            width: 600,             
            caption: "Grouping Array Data",
            loadComplete: function (data) {
                console.log("### data: " , data);  //Document
                console.log("### data.length: " , data.length);  //undefined
            }
        });
    })  

After server response the table is contained by data. Everythig looks correct. Is there any any idea why the data.length is undefined?

P̲̳x͓L̳
  • 3,615
  • 3
  • 29
  • 37
amigo
  • 343
  • 5
  • 19
  • 1
    What do you mean by "Document"? If `data` is the xml document you loaded (like the docs indicate), then it does of course not have a `.length` property. What did you expect it to be? – Bergi Mar 30 '14 at 17:56
  • @Bergi, I wanted to change the icon for each item of the first level of TreeGrid as described [here](http://stackoverflow.com/questions/9480708/jqgrid-treegrid-custom-css-class-for-each-tree-level/9482049#9482049). The commenter loaded the data using json hense there is a lenght property in that case. And in my case the response type is xml, that's why there is no a length property. I got it. Very thanks! Please, "post your answer" in order I can check the post as soleved. – amigo Mar 30 '14 at 19:42

1 Answers1

1

You're loading your data as an XML document (datatype: "xml"), and you are getting a Document back as seen in the log statement. Those don't have a .length, but collections of child nodes which you can iterate.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375