dojo editable-tree-dgrid : create or generate a new row supported in the dojo.store.JsonRest?

送分小仙女□ 提交于 2019-12-04 02:11:27

问题


I am trying a dojo-dgrid which is both Tree and Editable.
In that I have the requirement as follows,

I have a Add Button/Icon in a column(usually last column) for the parent rows. On clicking that Icon,
a new Child-row should get generated/created (like store.newItem()) under this parent Row
and this child row should be editable (there are 11 columns out of which 6 are editable,3 of them are digit.form.Select and the other 3 are Text-fields).

Upon filling the editable areas , (there will be a Save Icon in the last column) clicking the save-icon should save this new Child row.

Btw, I am using the dojo.store.JsonRest as store .

Grid Declaration is as follow:

var MyGrid = declare([Grid, Selection, Keyboard]);
window.testgrid = new MyGrid( 
{
    store       : Observable(Cache(jsonRest, Memory())),
    selectionMode : "none",
    getBeforePut: false,
    columns: getColumns,
    allowSelectAll: true,
    minRowsPerPage: 5,
    maxRowsPerPage: 20,
}, "gridContainer");

Another question related to multiple Cell edit for this same grid was posted here.

In JsonRest , I could see only add,put,delete kind of methods. Wondering how to accomplish this requirement with JsonRest as store.

Thanks.


回答1:


You would want to use put. The put method of the store is meant to insert or update an item.

var default_values = {somefield:'somevalue'};
default_values['parent'] = parent_id; //I have not actually defined parent_id
testgrid.store.put(default_values).then(function(result) {
    testgrid.refresh();
});


来源:https://stackoverflow.com/questions/13176157/dojo-editable-tree-dgrid-create-or-generate-a-new-row-supported-in-the-dojo-st

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!