Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Duncan Bean on Jul 11, 2008 07:19
open dhtmlx forum
selectCell after resizing dhtmlxgrid

I have created a grid with the onEditCell event attached at initialisation. This calls a function which validates for mandatory fields, numerics, dates, times etc. when stage=2 (cell has been left).

If an error has occurred then a further function is called :

    /*
     * Set cell focus
     */
    focusCell : function(rowID,cellIndex){
        window.setTimeout(function(){
            trent.rostering.feed.Forecast.grid.selectCell(rowID,cellIndex);
            trent.rostering.feed.Forecast.grid.editCell();
            },1);
        trent.rostering.feed.Forecast.grid.select();
    },

This works well until the grid is resized by changing the style height of the container div (by the user selecting a link), followed by grid.setSizes(); to resize the grid contents correctly. When this is done the focusCell function fails and does not return focus to the correct cell. Resizing back to the original size corrects the problem.
Answer posted by Support on Jul 11, 2008 07:59
The changing of grid's sizes must not affect any other logic in grid.

>> fails and does not return focus to the correct cell
Can you please provide more details, does it not select necessary cell at all, or just not move it in visible part of grid?
In second case you can force behavior by adding
         trent.rostering.feed.Forecast.grid.showRow(rowID);

also, you are using selectCell function with rowID as parameter, but this command must receive row index as parameter, not ID
Answer posted by Duncan Bean on Jul 11, 2008 08:12
  1. When re-sized it selects the cell that is currently under the mouse pointer.
  2. At what point do you suggest using showRow?
  3. RowID is the variable returned by attaching onEditCell for example:

trent.rostering.feed.Forecast.grid.attachEvent("onEditCell",trent.rostering.feed.Forecast.startMod);

startMod : function(stage,rowID,cellIndex,newVal,oldVal){

this variables value is passed into grid.selectCell

 

Answer posted by Support on Jul 11, 2008 10:01
>>RowID is the variable returned by attaching onEditCell for example:
Value provided by event is a rowID, this is correct, but selectCell requires index
        trent.rostering.feed.Forecast.grid.selectCell(trent.rostering.feed.Forecast.grid.getRowIndex(rowID),cellIndex);
This is not necessary if you have IDs equal to Indexes, but strongly recommended

>>At what point do you suggest using showRow?
            trent.rostering.feed.Forecast.grid.selectCell(...
            trent.rostering.feed.Forecast.grid.showRow(...
            trent.rostering.feed.Forecast.grid.editCell(...