Dojo Datagrid添加新项目后进行排序 [英] Dojo Datagrid Sort after adding New Item to Store

查看:161
本文介绍了Dojo Datagrid添加新项目后进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在DataGrid上遇到问题,在调用newItem()然后将save()保存在支持datagrid的商店时,不会自行调用。

I'm having an issue with a DataGrid not resorting itself after calling newItem() then save() on the store backing the 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

An event handler calls the following javascript

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

一个新项目被添加到商店,DataGrid被更新显示新项目。但新项目位于列表的底部。它似乎不能识别datagrid的排序顺序。

A new item is added to the store, and the DataGrid is updated showing the new item. But the new item is at the bottom of the list. It doesn't seem to recognize the sorting order of the datagrid.

我在想,有一个事件我需要连接到(或订阅)在datagrid这告诉我它已经更新了数据。然后当这个事件触发时,我调用sort / filter函数。但是要连接/订阅什么?

I'm thinking there is an event I need to connect to (or subscribe to) on the datagrid which tells me it has updated the data. Then I call sort/filter functions when this event is fired. But what to connect/subscribe to?

推荐答案

我在第二天遇到困难。我想你需要从你的onComplete函数的内部调用datagrid的sort()方法,你已经命名为afterStoreUpdate

I was struggling with this the other day. I think you need to call the sort() method of the datagrid from inside of your onComplete function, which you have named afterStoreUpdate

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

这篇关于Dojo Datagrid添加新项目后进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆