Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Udaya on Jun 22, 2008 20:04
open dhtmlx forum
Move row

Hello,
Iam using the move row functionality.When i select a row and move up or down,i want just want to get the selected row id and the row id which is one below or above the selected one.

Iam triggering the following fn when move row up button is clicked,
     function moveRowUp()
     {    
        var sequenceList =new Array();
        Grid.moveRowUp(Grid.getSelectedId());    
        sequenceList.push(Grid.getSelectedId());
        alert("sequenceList"+sequenceList);
}
With this function iam able to get the row id of the selected row,but i want to get the id of the row which is below the selected row.

I tried geting it with row index..but even that is not working.

something =1;
     function moveRowUp()
     {        
        var sequenceList =new Array();
        Grid.moveRowUp(RecurringGrid.getSelectedId());

        var selectedRowIndex = Grid.getRowIndex(Grid.getSelectedId());
        var BelowselectedRowIndex = Grid.getRowIndex(Grid.getSelectedId() - something);
        
        sequenceList.push(RecurringGrid.getRowId(selectedRowIndex));
        sequenceList.push(RecurringGrid.getRowId(BelowselectedRowIndex));

        something=something+1;
        alert("sequenceList"+sequenceList);
}
In this case its working at times but showing some other values when i select a different row and do move up.
Please tell me how to get the selected row id and exactly the id which is one below the selected one,every time i do the move row.


Also when i try geting the column values for the selected row id its not working..Its giving something like this.
c has no properties
[Break on this error] var cell = (c._childIndexes ? c.childNodes[c._childIndexes[col]] : c.childNode...

Please tell mw how to get the two row id's and the column values.
Note : In my case the row id's are not in sequential order.But they are unique.
Answer posted by Support on Jun 23, 2008 02:03
>>Please tell me how to get the selected row id and exactly the id which is one below the selected one
You approach is correct, but there are few strange things with code
a) You are using two different grid objects Grid and RecurringGrid
b) The something must be a 1 , always, but it is increased in your code for some purpose
c) You are mixing rowID and row indexes

The correct code will look as

     function moveRowUp()
     {        
        var sequenceList =new Array();
        Grid.moveRowUp(
Grid.getSelectedId());

        var selectedRowIndex = Grid.getRowIndex(Grid.getSelectedId());
        var BelowselectedRowIndex = selectedRowIndex - 1;
        
        sequenceList.push(
Grid.getRowId(selectedRowIndex));
        sequenceList.push(
Grid.getRowId(BelowselectedRowIndex));

        alert("sequenceList"+sequenceList);
}

>> .Its giving something like this.  c has no properties
Such error occurs when you are using non-existin rowID or rowIndex while accessing cell value.
Please be sure that you are using correct rowID ( not row Index )