Hi all,
I want to move the second row up and bring the third row to second position down in grid
like this i will movw up any row in grid
so i delete that row index and insert to new row in to my desired index in the grid and i store the values in idand i set the value to the new row
Is ithe code correct?
var grid=igtbl_getGridById("UltraWebGrid1");rowindex=igtbl_getActiveRow("UltraWebGrid1")
var row=grid.Rows.getRow(rowindex);var id=actrow.cells.fromkey(id)grid.Rows.remove(rowindex);rowindex=rowindex+1grid.Rows.insert(row, rowindex);
row.cell(0).setvalue(id))assigning thevalues to new row)can any one suggest me?
What happens with the current code? Could you explain the problem?
I can see some syntax issues in current code. Let me know if you want me to correct the code.
Also let me know that why you want to change the Id after swapping the rows.
Yes this code is not working it opens the add new function and
delete the selected row .i wrote the above function in cell click handler of grid..
I want to keep a upbutton and down button in my each row of grid and if i click the up button that selected row should move up
and if click down button the row should move one position down
Any other idea to move the selected row up or down?
I got the above code from net by searching..
can u suggest me any good idea and correct my mistakes to make the code work well
Hi,
I have created a sample and attached it.
In the sample I have created two separate functions for up and down which could also be used independently.
Let me know if this helps you.
Regards
Thank u for ur code..now i want to interchange the values of sortid in the grid..
can i take the prev row in values and sore in variable and assign to the newly added row ..
How to take the prev row values?if i move up the second row in grid to first row the sort id i should interchange..
can u give me any idea..
I think that there is no need to swap any Id. Because when you shift rows up and down complete row with the all cell gets shifted.
This change also changes the row order in server side grid.Rows collection. I think you can save the new sequence by iterating through the grid.Rows collection.
Try this code to verify it.
protected void Button1_Click(object sender, EventArgs e)
{
string childRows = String.Empty;
foreach (UltraGridRow row in grid1.Rows)
childRows += row.Cells.FromKey("RowNumber").Value + ",";
}
Label1.Text = childRows;
You should be able to see the changed rows sequence after moving rows to up or down.
There is a big possibility that I didn’t understand your requirements correctly. In that case please correct me. I would try to think in that way.
Still you can check this and let me know if this works for you.
Thank u for your reply..
I will shift the second row to first row ,so all the second row values goto first row..
after interchnaging the row -but i dont want to interchnage the sortid column - id name
before move up:
Sortid name
1 A
2 B
after move up
If i move up the second row B means the required ans is :
1 B
2 A
can u give any idea for this
can i store the both row values before interchanging in a variable and assign after interchanging
Hello,
You can create a simple function which can swap the Id. You can check following code for quick reference.
funtion SwapId(row1,row2)
var tempId = row1.getCell(0).getValue();
row1.getCell(0).setValue(row2.getCell(0).getValue())
row2.getCell(0).setValue(tempId);
call this function in both the row shifting functions e.i MoveUp and MoveDown.
thank u for ur reply and idea...
it works fine..