Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>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.</p> <p>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.</p> <p>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.</p> <p>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)</p> <p>Here is a fiddle with a basic create, update, and delete operation: <a href="http://jsfiddle.net/BC7yT/11/" rel="noreferrer">http://jsfiddle.net/BC7yT/11/</a></p> <p>These examples all take advantage of declaring an identity when creating the store.</p> <pre><code>var store = new dojo.data.ItemFileWriteStore({ data: { identifier : 'planet', items: itemList } }); </code></pre> <p>UPDATE AN EXISITNG ITEM:</p> <pre><code>//If the store is not in your scope you can get it from the grid var store = grid.store; //fetchItemByIdentity would be faster here, but this uses query just to show //it is also possible store.fetch({query : {planet : 'Zoron'}, onItem : function (item ) { var humans = store.getValue(item, 'humanPop'); humans += 200; store.setValue(item, 'humanPop', humans); } }); </code></pre> <p>INSERT A NEW ITEM:</p> <pre><code>store.newItem({planet: 'Endron', humanPop : 40000, alienPop : 9000}); } catch (e) { //An item with the same identity already exists } </code></pre> <p>DELETE AN ITEM: </p> <pre><code>store.fetchItemByIdentity({ 'identity' : 'Gaxula', onItem : function (item ) { if(item == null) { //Item does not exist } else { store.deleteItem(item); } }}); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload