Columns ColumnMenu initialization

3 posts, 0 answers
  1. Michel
    Michel avatar
    42 posts
    Member since:
    Sep 2011

    Posted 24 Apr Link to this post

    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. Dimiter Topalov
    Admin
    Dimiter Topalov avatar
    603 posts

    Posted 24 Apr Link to this post

    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.
  3. Michel
    Michel avatar
    42 posts
    Member since:
    Sep 2011

    Posted 24 Apr in reply to Dimiter Topalov Link to this post

    Hi Dimiter,

    It work like a charm.

    Thanks

Back to Top