dojo dgrid multiple cells edit

Deadly 提交于 2019-12-18 12:49:12

问题


Is it possible to edit multiple cells of the dgrid at the same time ?

I know that we can edit a single cell at a time by double/single clicking that cell and update it. And on the onBlur of that cell, the edited data gets updated for that cell.

But my requirement is:

  1. click edit-link/edit-button for each row, which will display editors for the all the editable cells of that row,
  2. update/edit the cells,
  3. then click the save button(which will be next to the edit button) for that same row,
  4. on clicking the Save link/icon , the edited cell's value should get saved to the store/server.

Below are some of the columns of the Grid.

// one of the editable columns others are also similar to this one.. 
          editor({
                    label:"Outcome", 
                    field:"outcome", 
                    sortable: false, 
                    editorArgs: {
                        options:[
                                  {value: "1", label: "Opt1"},
                                  {value: "2", label: "Opt2"},
                                  {value: "3", label: "Opt3"},
                                ]
                    }, 
                    renderCell: function(row, value, td, options){
                        put(td, "div", outcomeOptionsMap[value] || '');
                    }
                }, Select, "dblclick" ),


// last column
                {label:"Actions", field:"actions",sortable: false, 
            renderCell: function(row, value, td, options){
            newValue = "<a href=\"#\" title=\"Edit\" onclick='editEntireRow(testgrid,event);'><img src='../static/images/edit.gif'/></a>";
            newValue = "<a href=\"#\" title=\"Save\" onclick='saveRow(testgrid,event);'><img src='../static/images/edit.gif'/></a>";
            newValue += "  <a href=\"#\" title=\"Delete\" onclick='testgrid.store.remove("+row.id+");'><img src='../static/images/delete_icon.png'/></a>";
            td.innerHTML = newValue;
            }   

BTW, I am using the dojo.store.JsonRest as store .
Grid Declaration

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");

currently I am trying something like this, but not working...

function editEntireRow(grid,event){
// cols 3,5,7,8 steps to the left of the Action column are editable
grid.edit(grid.left(grid.cell(event),3));
grid.edit(grid.left(grid.cell(event),5));
grid.edit(grid.left(grid.cell(event),7));
//grid.edit(grid.left(grid.cell(event),8));
}

来源:https://stackoverflow.com/questions/13027345/dojo-dgrid-multiple-cells-edit

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