How to Place New Items to beginning of a Dojo Data Grid / Data Store

1060
1
12-18-2013 04:58 AM
ThomasHynes
New Contributor III
So I have a search function that populates the a Datagrid through it's data store and a manual selection tool that adds or removes items from the grid.  Items are added with: data_store.newItem(data);

The add function places the new items at the end of the grid.  I would like this new entry to populate the new item at the top of the grid.  Since I am using the data store and not an array, I can't use a function like unshift to place at the beginning of the array.  I thought I had seen someone on these forums solve this before, but I can't find the post.  Ideas anyone?
0 Kudos
1 Reply
JonathanUihlein
Esri Regular Contributor
So I have a search function that populates the a Datagrid through it's data store and a manual selection tool that adds or removes items from the grid.  Items are added with: data_store.newItem(data);

The add function places the new items at the end of the grid.  I would like this new entry to populate the new item at the top of the grid.  Since I am using the data store and not an array, I can't use a function like unshift to place at the beginning of the array.  I thought I had seen someone on these forums solve this before, but I can't find the post.  Ideas anyone?


Have you tried using sort based on a predictable property?

If you don't have a great property to sort on, you could have a hidden property that acts as a sorting mechanism for new items added to the store. All older items might have sort=1, while items you've added to the store recently have sort=0, and you'd sort your store based on that hidden field.

Last question, have you tried using dgrid over datagrid? It's far far easier to use and included in the ESRI JSAPI.
0 Kudos