Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Thukarama Prabhu on Mar 16, 2009 14:20
open dhtmlx forum
Block deletion in DHTML grid

Hi

Good morning

I do think I have some feature required for my application which maynot be available with current version of DHTMLX grid. I do use DHTMLX Grid and Tree in my present application. Initially client requested for block selection and copy/paste the data into grid. But recently they requested for block deletion functionality. As I could see this feature is not available with current available version of DHTML grid, could you please recommend some solution to resolve issue.

Requirement:

If user selects blocks of cells in DHTML grid and try to delete, he/she should be able to delete the data. Currently I have only copy & paste feature available.

Your suggestion would be of great help to me.

Thanks
Prabhu
Answer posted by dhxSupport on Mar 17, 2009 03:38

You can use "onKeyPress" event to define custom action on delete button pressing:

mygrid.attachEvent("onKeyPress",doOnKeyPressed);

...

function doOnKeyPressed(code,ctrl,shift){

if (code==46){
  if (mygrid._selectionArea){
    var leftTopRowInd=mygrid._selectionArea.LeftTopRow;
    var leftTopColInd=mygrid._selectionArea.LeftTopCol;
    var rightBottomRowInd=mygrid._selectionArea.RightBottomRow;
    var rightBottomColInd=mygrid._selectionArea.RightBottomCol;
  for (var i=leftTopRowInd; i<rightBottomRowInd+1;i++){
  for (var j=leftTopColInd; j<rightBottomColInd+1; j++){
  mygrid.cellByIndex(i,j).setValue("");
  }
  }
  }
  else alert ("please select any cell to delete it")
  }
  return true;

}