0

I have an XMLStore I'm using for the source of a DataGrid. I'm able to pull out top-level fields for use in the data grid, however I can't figure out how to pull out deeply nested fields from the XML.

Here's a sample of my XML data:

<ns1:CourseDetail>
 <ns1:subject_code>ABC</ns1:subject_code>
 <ns1:catalog_nbr>100</ns1:catalog_nbr>
 <ns1:descr>Some Class</ns1:descr>
 <ns1:MeetingCollection>
    <ns1:Meeting>
       <ns1:meeting_nbr>1</ns1:meeting_nbr>
       <ns1:InstructorCollection>
          <ns1:Instructor>
             <ns1:fullname>John Smith</ns1:fullname>
             <ns1:id/>
          </ns1:Instructor>
       </ns1:InstructorCollection>
       <ns1:bldg_id>999</ns1:bldg_id>
    </ns1:Meeting>
 </ns1:MeetingCollection>
</ns1:CourseDetail>

And here's the javascript I'm using to set up the grid:

var gridOptions = {
  store: sectionStore,
  query: {"ns1:subject_code": "*"},
  structure: [
      {name: "Class", field: "ns1:catalog_nbr", width: "150px"}
    , {name: "Desc", field: "ns1:descr", width: "250px"}
    , {name: "Instr", field: "ns1:fullname", width: "200px"}
  ]
};

var grid = new dojox.grid.DataGrid(gridOptions, "sectionsDataGrid");
grid.startup();

I can get the catalog number and description to show up just fine in the DataGrid, but I've tried a bunch of things to target the instructor name without success so far.

How can you define a field that targets a nested element?

4

1 回答 1

0

看起来唯一的方法是在网格上实现 get-functions 以进行数据检索,然后排序是一个额外的痛苦: 当以声明方式创建 dojox.grid.DataGrid - 如何在字段属性中指定嵌套数据?

我的 JSON 存储也有类似的问题,我最终转换为并序列化纯 DTO,而不是具有嵌套属性的实体。

于 2012-04-11T20:08:46.400 回答