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

Move contents of a cell up or down within the grid view.

6 Answers 58 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 2
Greg asked on 27 Jun 2011, 03:16 PM
Hello,

I'd like to move the contents of a selected row's single cell up or down with in the grid based on the user clicking an up or down button.
In the below example row 3 is selected and the user has clicked the UP button. The result shows that the LABEL data for row 2 and row 3 have been switched. I'd also like to move the selected row in the direction indicated with the button push. In this case the selected row moves from row 3 to row 2.

Thanks, G

EXAMPLE:          RESULT:

#     Label            #     Label    
1     1                   1     1
2     2                   2     3
3     3                   3     2
4     4                   4     4

6 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 27 Jun 2011, 03:41 PM
Hi Greg,

I am afraid that RadGridView has no such functionality built-in. Are you aware of any data grid out there that has it?

Greetings,
Ross
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
Greg
Top achievements
Rank 2
answered on 27 Jun 2011, 03:57 PM
Hi Ross,

Why yes I do know of a data grid that does this. However, it's been deprecated and I'm not sure if the ability has been continued in their new line of controls. I'm migrating existing VB6 code to C# and our VB6 code uses Sheridan controls, now Infragistics. That being said of course the old control wasn't using data binding. Not sure this would even be possible with bound data.

I think I can accomplish this with a foreach loop on the bound data. Luckily, there are usually only a few rows in the grid at any one time.
Greg
0
Avi Avni
Top achievements
Rank 1
answered on 28 Jun 2011, 07:06 AM

Hi Greg

We implements this factuality like this:

private void OnMoveDownButtonCommand(object param)

{

if (SelectedItem == nullreturn;

object movedItem = SelectedItem;

int index = ((IList)RadGrid.ItemsSource).IndexOf(movedItem);

if (index >= RadGrid.Items.TotalItemCount - 1) return;

 

if (index < 0)

{

  index = 0;

}

if (index % PageSize == PageSize - 1)

{

  RadGrid.Items.MoveToNextPage();

}

RadGrid.Items.Remove(movedItem);

index++;

((IList)RadGrid.ItemsSource).Insert(index, movedItem);

RadGrid.SelectedItem = movedItem;

RadGrid.ScrollIntoView(movedItem);

}

 

Hope this help

Best regards

Ehud

0
Raj
Top achievements
Rank 1
answered on 12 Apr 2012, 05:51 PM
Hi,
I need to implement the row move up and down in radgrid,each row have up and down imagebuttons.please let me know.


Thanks,
Raj
0
Abdul
Top achievements
Rank 1
answered on 22 Jun 2017, 09:23 AM

Hi Rossen Hristov,

I need to implement the row move up and down in RadGridView using RadButtons.I am waiting for your reply.

Regards

ABDUL HAFEEL

0
Martin Ivanov
Telerik team
answered on 27 Jun 2017, 09:26 AM
Hi Abdul,

To achieve your requirement you can use the Avi's approach and add the command logic to the buttons command. 

I also attached a small example demonstrating an alternative approach. I hope it helps.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Greg
Top achievements
Rank 2
Answers by
Rossen Hristov
Telerik team
Greg
Top achievements
Rank 2
Avi Avni
Top achievements
Rank 1
Raj
Top achievements
Rank 1
Abdul
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or