dojo editable-tree-dgrid : 创建或生成 dojo.store.JsonRest 支持的新行?

2022-01-18 00:00:00 grid javascript dojo dgrid

我正在尝试一个既是树又是可编辑的 dojo-dgrid.
我的要求如下,

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

我在父行的列(通常是最后一列)中有一个添加按钮/图标.单击该图标时,
应该在此父行下生成/创建一个新的子行(如 store.newItem())
并且这个子行应该是可编辑的(有 11 列,其中 6 列是可编辑的,其中 3 列是 digit.form.Select,另外 3 列是文本字段).

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.

顺便说一句,我使用 dojo.store.JsonRest 作为 store .

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

网格声明如下:

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.

在 JsonRest 中,我只能看到 add、put、delete 类型的方法.想知道如何使用 JsonRest 作为存储来完成此要求.

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

谢谢.

推荐答案

你会想要使用 put.store 的 put 方法用于插入或更新项目.

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();
});

相关文章