Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted on Apr 09, 2008 10:04
open dhtmlx forum
single click edit

can we enable cell editing on single click for some specific cells in the grid??? Right now i see that we can ebable single click edit on all the cells in the grid using enableEditEvents(click, dblclick, f2Key). But can we have single click edits for some columns in the grid and double click edit for the others???
Answer posted by Support on Apr 10, 2008 02:01
There is no API method for such functionality , but you use next code

    grid.enableEditEvents(false,true); // edit by dbl-click
    grid.setOnRowSelectHandler(function(id,ind){
       if (some_check(id,ind)   // for some cells
          this.editCell();             // switch to edit state by single click
       return true;
    },true);
Answer posted on Apr 10, 2008 08:48
Can you please be more clear about some_check(id,ind) ?? Iam not able to get it to work. Say i have a grid with 8 columns and i would like to enable single click edit on columns 1,3,4 and the rest would be double click edits. How can this be done??
Answer posted by Support on Apr 10, 2008 09:55
>>Can you please be more clear about some_check(id,ind) ??

It means you can place any check here

>>How can this be done??
    grid.enableEditEvents(false,true); // edit by dbl-click
    grid.setOnRowSelectHandler(function(id,ind){
       if (ind == 0 || ind == 2 || ind == 3)   // for columns 1,3,4
          this.editCell();             // switch to edit state by single click
       return true;
    },true);
Answer posted on Apr 10, 2008 12:04
I tried the above code and it only works when we select a row by clicking on the column for which we are cheking the index for. So for example if we select a row by selecting a cell of column 0 the edit would happen on that cell in one click but now that the row is selected the single click edit dosent work on rest of the cells (2,3).
Answer posted by Support on Apr 11, 2008 02:12
Please check attached sample
By default, handler attached by setOnRowSelectHandler fired only once, but if it was init with true as second parameter it will work for any click

   grid.setOnRowSelectHandler(function(id,ind){
       ....
    },true);
Attachments (1)