Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by zorlac on Jun 20, 2008 15:58
open dhtmlx forum
whole row edit mode

We have a requirements in the grid to have an action column. This action column has an edit and delete link (anchor) in every row that when clicked will make the whole row in edit mode (i.e. column1 - textbox, column2 - dropdown, column3 - calendar) and remove the whole row respectively.

Is there a method that I could make the whole row in edit mode or should I do this through javascript (like enabling edit mode in each cell or the row).
Answer posted by Support on Jun 23, 2008 01:33
The single cell can be switched to edit state as
    grid.selectCell(row_ind,cell_ind, flase, true); // 4th parameter - edit mode

The native edit capability supports only one edit cell per grid in one moment of time. It not possible to have multiple editable cells in same time.
As possible solution you can use static "ro" cells, and use something similar as
    grid.cells(i,j).setValue("<input type='text'>");
Answer posted by zorlac on Jun 23, 2008 14:32

Could you please enlighten me how you change the cell into textbox, combobox, radio button etc. when I clicked on it. I was wondering if I could call the same function you were calling when I clicked on the cell and change it to textbox, combobox etc.. , but do it iterating through the cell. Because data in a row is a related information, for usability if you want to edit information in a row u should somehow have some trigger (button, link) to enable that row to be edited  giving a hint to the user the data in the row could be edited. 

If we do make the row in edit mode by doing   "grid.cells(i,j).setValue("<input type='text'>");" that defeats the grid auto edit feature without much code. We just want the same functionality when click on the cell and changing it to edit mode, but we just want the whole row to be in edit mode.

Answer posted by Support on Jun 24, 2008 02:05
Technically the call of
    grid.cell(i,j).edit()
will transform cell to edit state  ( transform static text to input ), but grid was build for case when only one cell may be in edit state in same moment of time.
By using edit() command it possible to switch multiple cells to edit cell at once, but other functionality of grid may be broken.

var editors;
    function edit_start(id){
        editors=[];
        mygrid.forEachCell(id,function(c){
            editors.push(c);
            c.edit();
        })
    }
    function edit_stop(id){
        for (var i=0; i < editors.length; i++) {
            editors[i].detach();
        };
    }

Answer posted by zorlac on Jun 24, 2008 07:36

Thank you very much that answer my question.

I was wondering though what other functionalities that might be broken when multiple cell are in edit mode at once? So that I could put some constraint or disabling this functionalities on the grid once the user is in is editing multiple cell.

Answer posted by Support on Jun 24, 2008 08:38
Its hard to say, because such usecase was never seriously tested
To be safe, it is  better to disable edit before any actions which may access values of cells in edit state - such functionalities are :
    - serialization
    - clipboard operations
    - xml reloading or updateFromXML