How to add new item to top of Dojo DataGrid
I'm trying to implement a data item panel which is more like a mailing system. Where I need to add every new item to top of datagrid. After googling for a long time, I could still not find a proper dojo implementation of my requirement. Any help/gu开发者_Python百科idance me to achieve this will be appreciated
Thank you.
I think the question is that a new item should appear at the first row of the grid, instead of the last row. It looks like the email box, new emails are always put to the head of the mail list.
One possible solution I would suggest is to create you own data store implementation by extending the existing dojo.data.ItemFileWriteStore
. This store uses an array to store the items internally. When a new item is added, it's push
ed to the end of the array. You can override the newItem
function and use unshift
instead to add the item to the front of the array.
Another approach is to manage the items yourself. You can create an array to keep track of all the items. When a new item is added to the front of the array, just recreate the data store from the array and update the grid. That will work but have performance penalty.
Not sure I understand the question, but try looking at the grid example in the FileItemWriteStore documentation. HTH
Check the file dojo-release-1.5.0-src/dojox/grid/tests/test_edit_keyNav.html
There is a function in store called newItem() Just add an item in the store this will be added to the grid. Depending on the sorting in the grid the row is added to the grid.
If you you need some advanced techniques like server push check following url http://www.sitepen.com/blog/2010/10/31/dojo-websocket/
精彩评论