4 Answers, 1 is accepted
0
Hello Ragupathi,
Please find the answer to your question in this forum post:
http://www.telerik.com/community/forums/thread/b311D-bgbakc.aspx
Sincerely yours,
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please find the answer to your question in this forum post:
http://www.telerik.com/community/forums/thread/b311D-bgbakc.aspx
Sincerely yours,
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

jerry
Top achievements
Rank 1
answered on 16 Feb 2010, 03:47 PM
Nikolay,
How can I achive the same type of thing using up and down buttons?
I want to be able to move my rows around. When the current row moves up I want it's order column to decrease and the row above the current row to decrease. I have it almost working with this code
My problem is if I try and move the original row back up to it's original place the rowindex isn't correct.
What is the best approach for moving rows around in a gridview?
Thank You
How can I achive the same type of thing using up and down buttons?
I want to be able to move my rows around. When the current row moves up I want it's order column to decrease and the row above the current row to decrease. I have it almost working with this code
GridViewDataRowInfo t = gv.CurrentRow as GridViewDataRowInfo; |
t.Cells["ORDER"].Value = Convert.ToInt32(t.Cells["ORDER"].Value) - 1; //Moving Current row up - Sort based on Order |
GridViewDataRowInfo x = gv.Rows[s.RowIndex - 1] as GridViewDataRowInfo; //Row above current row |
x.Cells["ORDER"].Value = Convert.ToInt32(x.Cells["ORDER"].Value) + 1; |
gv.Columns["ORDER"].SortOrder = RadSortOrder.Ascending; |
gv.Refresh(); //Trying to get the row indexs correct |
My problem is if I try and move the original row back up to it's original place the rowindex isn't correct.
What is the best approach for moving rows around in a gridview?
Thank You
0
Hi jerry,
When RadGridView is sorted and you change a value in a sorted column, the rows' indices are changed immediatelly, so when you try to change the value of another cell passing a row index, you get wrong results, because the row index of the second row has already been changed.
I am attaching a sample project which demonstrates how you can change the row order in a sorted column. Basically, you need to use two separate loops for traversing rows instead of one.
I hope this helps. If you have additional questions, feel free to contact me.
Sincerely yours,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
When RadGridView is sorted and you change a value in a sorted column, the rows' indices are changed immediatelly, so when you try to change the value of another cell passing a row index, you get wrong results, because the row index of the second row has already been changed.
I am attaching a sample project which demonstrates how you can change the row order in a sorted column. Basically, you need to use two separate loops for traversing rows instead of one.
I hope this helps. If you have additional questions, feel free to contact me.
Sincerely yours,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

jerry
Top achievements
Rank 1
answered on 19 Feb 2010, 05:50 PM
Nikolay,
Thank you that is the same concept I was going for.
I'm turning off my sort within my grid till I add a new row set my order column then setting the sort back on and it works.
Thanks so much for yours and everyone else at Telerik for all your help on all my questions.
Jerry
Thank you that is the same concept I was going for.
I'm turning off my sort within my grid till I add a new row set my order column then setting the sort back on and it works.
Thanks so much for yours and everyone else at Telerik for all your help on all my questions.
Jerry