Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted on Apr 14, 2009 06:37
open dhtmlx forum
deleteSelectedRows selects the first cell

Hello,

I am using mygrid.deleteSelectedRows() for deleting multiple rows at a time. I see that this function by default selects the the first cell of the row.

How can I supress this behavior. I want the row to be selected but not call onrowselect function. Is there a way i pass in parameter [fl] which tells not to call onrowselect.

Please help me.

Thanks.
Answer posted by dhxSupport on Apr 14, 2009 07:10

By defauls this method doesnt call any events. It takes id's of the selected rows and deletes them. 

You can deny call "onRowSelect" event only if you are selecting row via API:

mygrid.selectRow(r, fl, preserve, show) where r - row index or row object, fl - if true, then call function on select, preserve - preserve previously selected rows true/false (false by default), show - true/false - scroll row to view, true by defaul. 

If you are selecting row with mouse "onRowSelect" event will be fired anyway. In such case you should check selected row ID and decide what should event handler do.

Answer posted on Apr 14, 2009 07:38

Hello,

Thank you for immediate reply.

I am using v.1.6 build 80603 for dhtmlxgrid.js

and following is the code for deleteSelectedRows()

this.deleteSelectedRows=function(){var num = this.selectedRows.length

 if (num == 0)return;var tmpAr = this.selectedRows;this.selectedRows=dhtmlxArray()
 for (var i = num-1;i >= 0;i--){var node = tmpAr[i]

 if (!this.deleteRow(node.idd, node)){this.selectedRows[this.selectedRows.length]=node}else {if (node == this.row){var ind = i}}};if (ind){try{if (ind+1 > this.rowsCol.length)ind--;this.selectCell(ind, 0, true)
 }catch (er){this.row=null
 this.cell=null
 }}};

Please note that the selectCell code in above function is triggering onRowSelect event. In my code Column index 0 is hidden.  This leads to problem. Can I completely remove this line and use deleteSelectedRows. Will that be ok.

Thanks.

 

Answer posted by dhxSupport on Apr 14, 2009 08:14

That command is used to select next row after deleted row. You can change this line like that:

this.selectCell(ind, 0, false);

after that "onRowSelect" event will not be fired.