【问题标题】:Using Nested Fields from an XMLStore in a DataGrid in Dojo在 Dojo 的 DataGrid 中使用 XMLStore 中的嵌套字段
【发布时间】:2012-04-02 07:13:26
【问题描述】:

我有一个用于 DataGrid 源的 XMLStore。我能够提取顶级字段以在数据网格中使用,但是我不知道如何从 XML 中提取深度嵌套的字段。

这是我的 XML 数据示例:

<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>

这是我用来设置网格的 javascript:

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();

我可以让目录号和描述在 DataGrid 中正常显示,但到目前为止,我已经尝试了很多方法来定位讲师姓名,但没有成功。

如何定义一个以嵌套元素为目标的字段?

【问题讨论】:

    标签: dojo dojox.grid.datagrid xmlstore


    【解决方案1】:

    看起来唯一的办法是在网格上实现获取函数以进行数据检索,然后排序是一个额外的痛苦: When declaratively creating a dojox.grid.DataGrid - how to specify nested data in the field attribute?

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-07-27
      • 2017-05-20
      • 2011-10-19
      • 2021-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多