質問

I am using DGRID to display data. I am aware i can query records in the store using store.query and insert records into the store using store.put and so on however i would like to do an update of the store. How can i update a record in the store?

I would prefer updating the memory store and then push that back into the database instead of updating the database first and then refreshing the memory store.

Data

 var data = [
            { id:"1", idType: "Passport", idNumber: "12121545WWW" },
            { id:"2",idType: "Drivers Permit", idNumber: "11212154515 FF"},
            { id:"3",idType: "Electoral Identification", idNumber: "425123123121"}
        ];

Functions

Add data

Store.put({id: enteredId, idNumber:enteredIdNumber,idType:enteredIdType})

Query data

Store.query({idType: enteredIdType})

Update data - i am confused how this is done

Store.update({idNumber:enteredIdNumber,idType:enteredIdType})
役に立ちましたか?

解決

You seem to be a bit confused about the dojo/store API.

  • store.add(item) is used to add new items
  • store.put(item) is used to update items, but can often also be used to add new ones with a specific ID
  • store.remove(id) is used to delete items

If you wrap your store with dojo/store/Observable, e.g. new Observable(new Memory({ data: ... })), then the grid will update automatically when add / put / remove are called.

See the dojo/store documentation for more information.

If you are wondering how to update records via the grid itself, have a look at the editor column plugin.

他のヒント

Do you have an example of what your store structure is like? Normally if your store identifier is your "id", putting it again will just update the row. After putting new data, you can just call on grid.refresh() and it should update your table.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top