This is a migrated thread and some comments may be shown as answers.

can i drag and drop the rows from in the grid ?

4 Answers 188 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ragupathi
Top achievements
Rank 1
Ragupathi asked on 11 Sep 2008, 11:36 AM
Can I drag and drop the row to reorder the rows in radgridview ?

Thanks in Advance
Ragupathi

4 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 12 Sep 2008, 04:18 PM
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.
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
 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
Nikolay
Telerik team
answered on 19 Feb 2010, 12:59 PM
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.
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
Tags
GridView
Asked by
Ragupathi
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
jerry
Top achievements
Rank 1
Share this question
or