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

UWP RadDataGrid: Column display order configuration save/render again from it.

10 Answers 130 Views
DataGrid
This is a migrated thread and some comments may be shown as answers.
Akash
Top achievements
Rank 1
Akash asked on 14 Jul 2017, 11:54 AM
Hello Support Team,

Kindly provide any way to get current column configuration(specially column display order after reordering) , So I can store this configuration in database and next time it will render from the configuration(Which is stored in last visit). 

10 Answers, 1 is accepted

Sort by
0
Akash
Top achievements
Rank 1
answered on 19 Jul 2017, 04:30 AM

Hello Support Team,

If we get the solution, we want to purchase the Telerik control for our development but it is highly depended on the requirement.
Can you please help me short-out it?     

Regards,
Akash

0
Nasko
Telerik team
answered on 19 Jul 2017, 06:24 AM
Hello Akash,

The DataGrid control provides a Columns collections property that you could use in order to get all the needed information including the order in which the columns are displayed. Could you please check it and let us know if it works for you in order to get the needed information?

We have also noticed you have asked the same question in another forum thread. I will post my answer there as well in order to be available for the other members of the community.

Hope this helps.

Regards,
Nasko
Progress Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Akash
Top achievements
Rank 1
answered on 19 Jul 2017, 11:08 AM
Hello Nasko,

 I have already checked Data Grid’s Columns collection, It’s helped me to get current display index infect the collection order (index) itself change according to the current display order. However, I cannot find any property inside the column object to get the current display order, It should be with a property like ‘OrderIndex’, I am looking for the same which is already available for Asp.net Telerik Control:  Check out the answer given by Maria Ilieva: http://www.telerik.com/forums/change-order-of-column-in-radgrid. 

It can help me to reconfigure column order using code. 

Regards,
Akash
0
Nasko
Telerik team
answered on 19 Jul 2017, 12:50 PM
Hello Akash,

The DataGrid for UWP does not provide OrderIndex. However, you could easily reorder the columns as desired using the Move method of the Columns collection. Basically you need to tell the method the index of the column you want to reorder and its new index. The column from the new index will be placed to the index of the column you are reordering. Please, check the attached sample that demonstrates the described above approach.

So, you could save the current index of the columns when the application is closed and using the move method to place it to the desired location when the application starts again.

Hope this helps.

Regards,
Nasko
Progress Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Akash
Top achievements
Rank 1
answered on 19 Jul 2017, 01:47 PM

Thank You Nasko,

I have checked the method and this is excellently what was needed, however I am facing a minor issue to unique identification for each column. Please take look on code snap and let me know i can fix it. 

<grid:RadDataGrid x:Name="grid" UserGroupMode="Disabled" UserFilterMode="Disabled" AutoGenerateColumns="False" UserSortMode="None" Grid.Row="2" ItemsSource="{Binding}">            <grid:RadDataGrid.Columns>                <grid:DataGridTextColumn Width="200" Header="Name" PropertyName="Name"  x:Name="C1"  />                <grid:DataGridTextColumn Width="200" Header="Age" PropertyName="Age"  x:Name="C2"/>            </grid:RadDataGrid.Columns>        </grid:RadDataGrid>   
foreach (var column in grid.Columns)
{
               var columnId= column.Name; //It is required to get X: Name property which can help to identify unique column, e.g. "C1" OR "C2"
                 
                //TODO My logic will be here for move specific column//
}
0
Akash
Top achievements
Rank 1
answered on 20 Jul 2017, 04:57 AM

Hello Nasko,

Above code snap ("column.Name") should give us the name property which we have set(e.g. "C1" OR "C2") in the XAML file. Unfortunately, it gives null value every time. Alternative property ("column.Header") might be useful, but It doesn't work for me as I need to deal with multi language so It can't be used for unique identification.

Oops, I have just noticed a very strange behavior, it works well when we remove the prefix ("x:") from the "Name" property in XAML and now i can access from code side.

Anyways, thanks Nasko for your support.

0
Akash
Top achievements
Rank 1
answered on 20 Jul 2017, 10:52 AM

Hello Nasko,

Right now, I am nearer to complete my code and I just need an event which can be fired immediately on each column re-order. Something like 'ColumnOrderChanged' Or ''ColumnOrderChanging'', Based on that I can store this change in the database. 

Regards,
Akash
0
Nasko
Telerik team
answered on 20 Jul 2017, 11:00 AM
Hi Akash,

You could handle the CollectionChanged event of the Columns collection and when the Move action is executed to save the desired values inside the database. Please, check the attached sample that demonstrates that.

We hope this will help you.

Regards,
Nasko
Progress Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Akash
Top achievements
Rank 1
answered on 12 Sep 2017, 12:49 PM
Hello Support Team, 

My requirement is change a bit, I need to set "visibility" of columns with "column width" and display order as well from database and changes need to be store in database back.

Can you help me to fix this requirement? 
0
Nasko
Telerik team
answered on 14 Sep 2017, 06:48 AM
Hello Akash,

We are not exactly sure we understand your requirements. If you need to change the visibility of the Column you could use the IsVisible property - that property indicates whether the column should be visualized. As for the width of the column please, check the following article from our documentation that provides detailed information how exactly fixed width could be set for the columns:
http://docs.telerik.com/devtools/universal-windows-platform/controls/raddatagrid/columns/how-to/datagrid-howto-setcolumnswidthusingsizemode

Both values after that you could save inside your database at a desired moment.

If that is not what you are looking for please, provide some more information what exactly you are trying to achieve and we will try to provide you with a solution if possible.

Regards,
Nasko
Progress Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
DataGrid
Asked by
Akash
Top achievements
Rank 1
Answers by
Akash
Top achievements
Rank 1
Nasko
Telerik team
Share this question
or