Dynamic Column data loading in DataGrid

0 Answers 208 Views
DataGrid
Ledcor Development Team
Top achievements
Rank 1
Ledcor Development Team asked on 22 Dec 2021, 10:50 PM

Hello,

Our application requires the ability to return dynamic columns (name/number) and we wanted to confirm with you if the DataGrid in Telerik UI for Xamarin can do that.

Example: query may return 3 columns with data (col1, col2, col3), or it can return 5 columns with data (colV, colW, colX, colY, colZ).

Thanks

Noor Huda

Didi
Telerik team
commented on 24 Dec 2021, 07:40 AM

Hi Myroslav, 

The DataGrid columns can be added dynamically. For example you can add / remove columns like:

DataGrid.Columns.Add
DataGrid.Columns.Remove


Sample demo: 

        <datagrid:RadDataGrid x:Name="dataGrid" AutoGenerateColumns="False"/>
  // and in code behind: 

this.dataGrid.Columns.Add(new DataGridTextColumn 
            { 
            HeaderText ="Header!" //etc.
            });
            this.dataGrid.Columns.Add(new DataGridTextColumn
            {
                HeaderText = "Header2" // etc.
            });
            this.dataGrid.Columns.Add(new DataGridTextColumn
            {
                HeaderText = "Header3", //etc
            });

You can add columns manually or automatically using the AutoGenerateColumns property.

For this scenario: query may return 3 columns with data (col1, col2, col3), or it can return 5 columns with data (colV, colW, colX, colY, colZ). using the AutoGenerateColumns  = "True" could be of help. You can test the DataGrid in the scenario you have. 

More details about DataGrid columns can be found here: =https://docs.telerik.com/devtools/xamarin/controls/datagrid/columns/columns-overview#columns-overview

  

No answers yet. Maybe you can help?

Tags
DataGrid
Asked by
Ledcor Development Team
Top achievements
Rank 1
Share this question
or