dojo dgrid multiple cells edit

2019-02-05 12:08发布

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

0条回答
登录 后发表回答