1

我有以下 xml 格式:

<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"><SOAP-ENV:Body>
<return>
<actions>
<action>
<ActionId>102</ActionId>
<PatientId>1234</PatientId>
<Priority>0</Priority>
<Recurrence>0</Recurrence>
<PtName>name, patient</PtName>
<ActionStatus>Not Started</ActionStatus>
<DueDate>05/04/2012</DueDate>
<AssignedTo>lname, assigned</AssignedTo>
<FacilityName>facility abc</FacilityName>
<CreatedBy>created by abc</CreatedBy>
<StartDate>05/04/2012</StartDate>
<Subject>General -</Subject>
<ActionType>test action</ActionType>
</action>
<action>....</action>
</actions><Total>3</Total></return>
</SOAP-ENV:Body></SOAP-ENV:Envelope>

我的 jqgrid 代码是:

    jQuery("#list1").jqGrid({
        datatype: 'xmlstring',
        datastr : stringXML,
        colNames:['ActionId','PatientId', 'Priority','Recurrence','PtName','ActionStatus','DueDate','AssignedTo','FacilityName','CreatedBy','StartDate','Subject','ActionType'],
        colModel :[ 
          {name:'ActionId', index:'ActionId', width:55 }, 
          {name:'PatientId', index:'PatientId', width:90}, 
          {name:'Priority', index:'Priority', width:80}, 
          {name:'Recurrence', index:'Recurrence', width:80}, 
          {name:'PtName', index:'PtName', width:80 }, 
          {name:'ActionStatus', index:'ActionStatus', width:80}, 
          {name:'DueDate', index:'DueDate', width:80}, 
          {name:'AssignedTo', index:'AssignedTo', width:80}, 
          {name:'FacilityName', index:'FacilityName', width:80}, 
          {name:'CreatedBy', index:'CreatedBy', width:80},
          {name:'StartDate', index:'StartDate', width:80},
          {name:'Subject', index:'Subject', width:80},
          {name:'ActionType', index:'ActionType', width:80},
           ],
        pager: '#pager',
        rowNum:10,
        viewrecords: true,
        caption: 'My first grid'
      }).navGrid('#pager1',{edit:false,add:false,del:false});        
}

但是,它无法绑定它。我已将 xml 放入变量 stringXML:

var stringXML = "以上xml";

我的 IE 调试器出现错误: SCRIPT5007: Unable to get property 'integer' of undefined or null reference jquery.jqGrid.min.js, line 130 character 62

真的很沮丧,我尝试编辑我的 xml :删除肥皂标签,但它不起作用。我不想将其转换为 json 然后绑定它的开销。但是,这也行不通。

4

1 回答 1

0

您可能需要定义一个可以解析您的 XML 数据的 xml Reader,如下所示:

xmlReader: { 
   root:"return", 
   row:"actions",
   cell:"action"
}

有关更多信息,请参阅jqGrid 文档

这有帮助吗?

于 2013-08-06T15:21:47.657 回答