RadGrid: How can I apply ColumnSettings to my grid columns?

0 Answers 96 Views
Grid
Sven
Top achievements
Rank 1
Sven asked on 05 Nov 2021, 09:56 AM

Hello,

I want to apply widths to certain columns, that are defined by a user. Since the columns themselves don't provide a Width-property, I tried to use the column settings of the MasterTableView.

I create the ColumnSettings like this:

string[] columnWidths = {"125", "164", "64", "125"};

foreach (string columnWidth in columnWidths)
{
    Grid.MasterTableView.ColumnSettings.Add(new GridTableView.PersistableColumnSetting
    {
           Width = columnWidth
    });
}

 

But I can't find any method to apply these settings to a grid column.
Do I miss something or is there an easier way to set the width of a column?

 

Sven
Top achievements
Rank 1
commented on 08 Nov 2021, 10:04 AM

Update: I just realised, you can set the width via the HeaderStyle of the column.
Attila Antal
Telerik team
commented on 08 Nov 2021, 10:27 AM

That is correct. The HeaderStyle-Width defines the width of <col > elements in the rendered table. Those dictate the column's (td) width. Also, be sure to use the correct TableLayout (MasterTable-TableLayout) as this dictates how the overall layout of the Table should be displayed regardless of the Column width. For more details you can check out this CSS Tricks article: table-layout - CSS Tricks

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Sven
Top achievements
Rank 1
Share this question
or