Is it possible to limit checkbox column's width?

Hi,

We can set width of columns and it works fine. When there are many columns in grid and user wants remove some columns by using Column Chooser, remaining columns adjust their width accordingly (as expected). In that case we don't want checkbox column to get too wide along with other columns.

I looked at some forum questions and tried some css solutions like the one below but they did not help.
https://www.syncfusion.com/forums/165289/column-min-and-max-widths-do-not-work-when-the-window-size-is-changed

Is it possible to limit checkbox column's width in such a scenario?

Thanks & kind regards


1 Reply

KG Keerthana Ganesan Syncfusion Team October 3, 2022 06:35 PM UTC

Hi Yunus,

Greetings from Syncfusion support.

Query: Is it possible to limit the checkbox column’s width?

We have analyzed your query and We suggest you use MinWidth and MaxWidth properties for the Grid Column. Kindly refer to the attached code snippet for your reference.

<SfGrid DataSource="@Orders" GridLines="GridLine.Default" AllowSelection="true" ShowColumnChooser="true" AllowTextWrap="true" Height="500" AllowResizing="true"  Toolbar=@ToolbarItems>

      

        <GridSelectionSettings Type="SelectionType.Multiple"></GridSelectionSettings>

        <GridColumns>

            <GridColumn Field=@nameof(Order.CheckBox) AutoFit = "true" HeaderText="Bool" MinWidth="50px" MaxWidth="100px" Type="ColumnType.CheckBox" CustomAttributes="@(new Dictionary<string, object>(){ { "class", "e-attr" }})"></GridColumn>

            <GridColumn Field=@nameof(Order.RollNo) HeaderText="Roll No" AutoFit="true"></GridColumn>

            <GridColumn Field=@nameof(Order.Name) HeaderText="Name of the inventor" AutoFit="true"></GridColumn>

            <GridColumn Field=@nameof(Order.PatentFamilies) HeaderText="No of patentfamilies" AutoFit="true"></GridColumn>

            <GridColumn Field=@nameof(Order.Country) HeaderText="Country" AutoFit="true"></GridColumn>

            <GridColumn Field=@nameof(Order.MainFields) HeaderText="Main fields of Invention" CustomAttributes="@(new Dictionary<string, object>(){ { "class", "e-attr" }})" ></GridColumn>

        </GridColumns>

    </SfGrid>


Kindly get back to us if you have any further queries.

Regards,

Keerthana.


Loader.
Up arrow icon