【问题标题】:Dojo Datagrid Sort after adding New Item to Store将新项目添加到商店后 Dojo Datagrid 排序
【发布时间】:2011-07-29 07:18:10
【问题描述】:

在支持数据网格的存储上调用 newItem() 然后 save() 后,DataGrid 没有自行解决问题。

<div dojoType="dojo.data.ItemFileWriteStore" url="/MultiRaterManagerAjax" id="mrWriteStore" jsId="mrWriteStore"</div>     

<table dojoType="dojox.grid.DataGrid" region="left" query="{ hasSub: false }"
        clientSort="true" selectionMode="single"   jsId="ldrSubGrid" sortInfo="1"
        errorMessage="Loading..." store="mrWriteStore">
          <thead>
              <tr>
                  <th width="100%" field="_item" formatter="formatSubs">Subs</th>     
              </tr>

          </thead>
</table>

事件处理程序调用以下 javascript

item = mrWriteStore.newItem({});
//set the necessary attributes on item
mrWriteStore.save({onComplete:afterStoreUpdate, onError: saveFailed});

一个新项目被添加到商店,DataGrid 更新显示新项目。但新项目位于列表的底部。它似乎无法识别数据网格的排序顺序。

我在想我需要在数据网格上连接(或订阅)一个事件,告诉我它已经更新了数据。然后在触发此事件时调用排序/过滤函数。但是要连接/订阅什么?

【问题讨论】:

    标签: sorting datagrid dojo


    【解决方案1】:

    前几天我正在为此苦苦挣扎。我认为您需要从 onComplete 函数内部调用 datagrid 的 sort() 方法,您已将其命名为 afterStoreUpdate

    dijit.byId('ldrSubGrid').sort();
    

    【讨论】:

    • 这适用于排序。谢谢。我不认为商店中的事件会是我想要在网格上排序的。在相同情况下仍然存在过滤问题,但我还没有足够的知识来提出问题。 onComplete: ldrSubGrid.filter({ hasSub: false,},null);没有做任何事情,但是在 Firebug 中正确过滤网格之后运行相同的代码。 JavaScript 有时很不稳定。
    • 它是包裹在这样的函数中的吗? onComplete: function() {ldrSubGrid.filter({ hasSub: false,},null); } 只是检查以确保
    猜你喜欢
    • 2014-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-18
    • 2010-11-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多