问题
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