Dojo Datagrid Sort after adding New Item to Store

安稳与你 提交于 2019-12-11 02:25:46

问题


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>

An event handler calls the following javascript

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

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.

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?


回答1:


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


来源:https://stackoverflow.com/questions/5541075/dojo-datagrid-sort-after-adding-new-item-to-store

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!