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

Columns ColumnMenu initialization

2 Answers 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michel
Top achievements
Rank 1
Michel asked on 24 Apr 2017, 09:57 AM

Is there a way to initialize the checkbox state of the Columns submenu when the ColumnMenu is enabled ?

I would like to have specific column checked and some unchecked by default.

Best regards.

2 Answers, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 24 Apr 2017, 10:58 AM
Hello Michel,

The checked state of the Columns sub-menu items represents whether a column is visible in the Grid and allows for hiding and showing Grid columns via the UI.

You can set the initial state of the columns via the Hidden() column configuration helper method - the ones that are initially hidden with Hidden(true) will be unchecked in the Columns sub-menu, while the initially visible ones will be checked, e.g. (based on this online demo, also available in the Sample application coming with your installation package):

@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.Order>()
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(o => o.OrderID).Width(120);
        columns.Bound(o => o.ShipCountry).Hidden(true);
        columns.Bound(o => o.ShipName);
        columns.Bound(o => o.ShipAddress).Filterable(false);
    })
    .Scrollable()
    .HtmlAttributes(new { style = "height: 550px" })
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(30)
        .Read(read => read.Action("ColumnMenu_Read", "Grid"))
     )
    .Pageable()
    .Filterable()
    .Sortable()
    .ColumnMenu()
)

I hope this helps, but if I am missing something, please describe the scenario, and the desired functionality in further details, so I can try providing a more to-the-point suggestion, if one is supported. Thank you in advance.

Regards,
Dimiter Topalov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Michel
Top achievements
Rank 1
answered on 24 Apr 2017, 01:06 PM

Hi Dimiter,

It work like a charm.

Thanks

Tags
Grid
Asked by
Michel
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Michel
Top achievements
Rank 1
Share this question
or