Copy sorting between two similar RADGRIDVIEW

1 Answer 30 Views
GridView
Peter
Top achievements
Rank 1
Iron
Iron
Peter asked on 07 Nov 2021, 02:59 PM | edited on 07 Nov 2021, 03:01 PM

Dear Supprot Team,

 

I have a tricky task to do, and i cant figure out how to approach. On the below screenshot you can see two grids (marked with red arrow)

They have one common key, the 'ITEM CODE'. I have to keep these grids in sync from sorting and filtering and scrolling point of view, and in 2 of 3 i could solve. I can keep sync between scrollbars, i can also filter the rows based on any column of the both grid, but im in trouble iwth the sorting.

If i sort by ITEM CODE in any of the both grid, it sorts the other grid too perfectly, i achieved it with this simple line:

         rgv_COVERAGE.SortDescriptors.Add(rgv_RAWMAT.SortDescriptors(0))

But the rest of the column names are different, and if i sort by any of them it doenst reflect on the other.

With other words, if i sort by 'STOCK' for example on the left grid (rgv_RAWMAT) then it will result a kinda random ordering in the
'ITEM CODE' column here, and it wont reflect the 'ITEM CODE' column and the others either of the right grid (rgv_COVERAGE).

Please help me how can i achieve that soring aplies on the opposite side to (by the key-column: ITEM CODE), independently of which columnheader i clicked to.

Million thanks 

Peter

 

1 Answer, 1 is accepted

Sort by
0
Dinko
Telerik team
answered on 10 Nov 2021, 11:56 AM

Hello Peter,

Thank you for the provided image.

If I have understood correctly your case, only the first column is equal for both grids. The result is kind of expected. If you sort the Stock column in the first grid, transferring the same SortDescriptor won't lead to the same result to the second grid. My suggestion here, if the user sorts a different column in the first grid, check which column is sorted and sort the second grid manually with the corresponding column. You could check the Setting Sorting Programmatically help article which I think will get in handy.

Can you give this article a try and let me know if this helps you?

Regards,
Dinko
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Peter
Top achievements
Rank 1
Iron
Iron
commented on 11 Nov 2021, 09:08 PM

Dear Dinko,

How do you mean 'manually with corresponding column'? there is no 'STOCK' or any other of columns on the other side , except the common key column 'ITEM CODE'
If i sort with 'STOCK' it sorts the ITEM CODE of the first grid as well in a random way - from the other grid point of view, so i cant transfer this random ordering, because there is no descriptor like that, only ascending and descending. What would be the descriptor.propertyname to the right grid if i push STOCK header of the left grid?

The best would be if i could pass the list of item codes in the childrows of the left grid after sorting, pass them to the right grid's 'item code' as a descriptor. But there is no such a thing...

Dinko
Telerik team
commented on 16 Nov 2021, 11:26 AM

I assumed that the other columns will have similar values in their cells but with different headers. Indeed, if only the Item Code column is the same there is no out-of-the-box way to transfer the SortDescriptor from one RadGridView to another. As you mentioned you can consider using the ChildRows collection of the sorted grid. You can create custom sorting as described in the Custom Sorting help article. In the CustomSorting event handler, you can sort the other grid by using the ChildRows collection of the sorted one. This approach will require custom code and I am afraid that we don't have such an example at the moment to demonstrate such a scenario. However, we have a Custom Sorting demo in our Telerik UI for WinForms Demo Application which demonstrates how you can create custom sorting. You could use this demo as a starting point to implement your scenario.
Tags
GridView
Asked by
Peter
Top achievements
Rank 1
Iron
Iron
Answers by
Dinko
Telerik team
Share this question
or