简体   繁体   中英

Why is the data.length undefined in jqGrid loadComplete function?

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM