I create dojox.grid.datagrid and I fill content from array like on example last example on page. During time, I change value of that array in code. How to refresh content of that grid ? How to load new data from changed array ?
相关问题
- Simple Dojo i18n implementation
- Dgrid set focus on cell
- Cannot create dijits via dojo.NodeList.instantiate
- Firefox does not honor Content-type header in xhrP
- Calling object methods internally in dojo
相关文章
- Constrain position of Dojo FloatingPane
- How to get the “value” of a FilteringSelect <se
- Difference between registry.byId and dom.byId in d
- The load sequence difference between template and
- Dijit TabContainer Events - onFocus
- Dojo populate combo box widget dynamically
- Dojox.grid.DataGrid - in a widget - only renders o
- Is there any javascript library to capture mouse/k
(I suppose you already have a working grid and you want to completely change the grid's store)
Create a new datastore with your new value :
(data is the reponse from an ajax request for me)
Change your grid's store with the new one :
Render :
To change values in the grid, you will need to change the value in the grid's store. The grid data is bound to the store data, and the grid will update itself as needed.
So the key is to understand Dojo's data api and how stores work in Dojo. Rather than manipulating the data directly in the grid, manipulate it in the store.
Ideally, the store is your array that you manipulate as the application runs and you should not be needing to sync the array to the grid. Just use the ItemFileWriteStore as your data holder unless thats not possible.
Also, using the dojo data identity api makes it much simple to find items in the grid if that is possible. Assuming you know when an item is updated, deleted, or changed in your application you should be able to modify the grid store as needed when the action happens. This is definitely the preferred approach. If you can't do that you will have to do a general fetch and use the onComplete callback to manually sync your arrays which will be very slow and won't scale well, in which case you may as well just create a new store all together and assign it to the grid with grid.setStore(myNewStore)
Here is a fiddle with a basic create, update, and delete operation: http://jsfiddle.net/BC7yT/11/
These examples all take advantage of declaring an identity when creating the store.
UPDATE AN EXISITNG ITEM:
INSERT A NEW ITEM:
DELETE AN ITEM:
This Will update Grid Store and refresh the View of the Grid in latest Version of Dojo 1.9
I had a server-side filtered EnhancedGrid, which was refreshing happily by changing the store, and shown in the other answers.
However I had another EnhancedGrid that would not refresh when a filter was applied. It may have been to do with the fact it was filtered client side (but data still coming from server using JsonRest store), but I don't really know the cause. Eitherway, the solution was to refresh with the following code:
It's hacky and strange, but if it all else fails...
The following code snippet can be used to update the grid:
EDIT:
Dogo data grid reference guide (add/remove rows example, updating grid data examples )
with this i can update a specifi row. this example is for a treegrid.