admin管理员组文章数量:1328589
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})
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})
Share
Improve this question
asked Mar 26, 2014 at 20:22
devdardevdar
5,65428 gold badges103 silver badges156 bronze badges
2 Answers
Reset to default 7You seem to be a bit confused about the dojo/store API.
store.add(item)
is used to add new itemsstore.put(item)
is used to update items, but can often also be used to add new ones with a specific IDstore.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.
本文标签: javascriptDgrid update data storeStack Overflow
版权声明:本文标题:javascript - Dgrid update data store - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742257588a2441913.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论