Grid menu (hiding/showing columns) and columns defaulting to invisible/hidden

4 posts, 0 answers
  1. Dave
    Dave avatar
    35 posts
    Member since:
    Oct 2012

    Posted 14 Oct 2013 Link to this post

    I recently added Grid Column Menus to my grid, primarily to give the user the ability to hide/show columns.
    .ColumnMenu(menu => menu.Columns(true).Sortable(false))

    I want some columns hidden by default, and the user to have the ability to display them if needed. So, using the MVC helpers, I set Visible(false) like so:
    column.Bound(c => c.Submitter).Title("Submitter").Visible(false);
    However, to my surprise, columns hidden in this manner do not show up in the column menu. It's like they don't exist.

    I was able to get it working correctly by loading all columns as normal and then hiding certain ones via JavaScript:

    $(document).ready(function () {
        var grid = $('#issueGrid').data('kendoGrid');
        grid.hideColumn('Submitter');

    But I have 2 issues with this:
    A) There is some graphical stutter as the columns are noticably loaded and then hidden.
    B) I shouldn't have to do this. Setting a column as .Visible(false) should still have that column appear in the Menus.

    Is this a bug? Why does setting a column as .Visible(false) cause it to act like it does not exist, in regards to the Column Menu? I wish I didn't have to write 10+ extra lines of script to do this.

    Thanks.
  2. Dave
    Dave avatar
    17 posts
    Member since:
    Jan 2009

    Posted 14 Oct 2013 Link to this post

    on the bound column set the IncludeInMenu true

    column.Bound(c => c.Submitter).Title("Submitter").Visible(false).IncludeInMenu(true)

    I use the Hidden instead of the Visible

    .IncludeInMenu(true).Hidden(true);

    so
    column.Bound(c => c.Submitter).Title("Submitter").Hidden(true).IncludeInMenu(true)
  3. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2272 posts

    Posted 15 Oct 2013 Link to this post

    Hello,


    As said above, in order to achieve this, you should use the Hidden(false) method instead of the Visible(false). This way the column will be included in the Grid's markup, but will be hidden initially.
    E.g.
    columns.Bound(o => o.ShipName).Hidden(true);


    Regards,
    Dimiter Madjarov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  4. Dave
    Dave avatar
    35 posts
    Member since:
    Oct 2012

    Posted 15 Oct 2013 Link to this post

    Interesting. Well, that works. Thanks.
Back to Top