Bug? Cannot hide column from column menu

6 posts, 1 answers
  1. Anna
    Anna avatar
    64 posts
    Member since:
    Jul 2015

    Posted 03 Feb 2016 Link to this post

    With the following grid setup, I cannot hide a particular column through the column menu. Is it a bug?

    Grid setup (plunk <= try reproduce it here!)

    • columnMenu: true
    • 1 column (FirstName) with locked = true, lockable = false, menu = false
    • 1 column (LastName) with locked = true, lockable = true
    • at least 1 more column with locked = false

    If I go to the grid's Column Menu, and go to Columns option. The LastName column's checkbox is disabled - I can't hide that column now. On the other hand, if LastName column has locked = false, the checkbox in the Column Menu is enabled, and I can hide the column.

    Best,

    Ama

     

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 05 Feb 2016 Link to this post

    Hello Ama,

    This is the default behavior of the frozen columns functionality, which requires at least one locked column to be visible. Detailed information on the locked columns could be found in the following help article:
    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Anna
    Anna avatar
    64 posts
    Member since:
    Jul 2015

    Posted 05 Feb 2016 in reply to Konstantin Dikov Link to this post

    Hi Konstantin,

    Please give my plunk a try. For my instance, I do have at least 2 visible locked columns, First Name, Last Name, and multiple visible unlocked columns. I don't see any reason why the Last Name column cannot be hidden.

     

    Best,

     

    Ama

  4. Dimo
    Admin
    Dimo avatar
    8485 posts

    Posted 10 Feb 2016 Link to this post

    Hello Ama,

    The column menu is not aware of columns with a menu: false setting. Since the LastName is the only frozen column in the Column Menu, and the menu knows that at least one frozen column must be visible, it does not allow it to be hidden.

    Please enable the column menu for the FirstName column. If needed, you can disable sortability or filterability specifically for this column.

    http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columns.sortable

    In case you would like to submit a feature request for changing this behavior, please refer to:

    http://kendoui-feedback.telerik.com/forums/127393-telerik-kendo-ui-feedback

    Regards,
    Dimo
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Anna
    Anna avatar
    64 posts
    Member since:
    Jul 2015

    Posted 11 Feb 2016 Link to this post

    Hello Dimo,

    What we really want is disallow user to hide the Name column. Is there a way to show the column in the menu, but show as disabled?

    ps. I still think for the scenario I presented, the menu should behave consistently to what's actually shown in grid - with 2 locked visible column, last name column should be allowed to hide. 

     

    Best,

     

    Ama

  6. Answer
    Dimo
    Admin
    Dimo avatar
    8485 posts

    Posted 15 Feb 2016 Link to this post

    Hello Ama,

    You can achieve the desired behavior by allowing the column menu to handle the Name column, but disable its checkbox programmatically in the columnMenuInit event.

    http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#events-columnMenuInit

    function onColumnMenuInit (e) {
        var checkbox = e.container.find(".k-columns-item ").find("input[data-field='YourFieldName']");
     
        checkbox.attr("disabled", "disabled");
        checkbox.closest(".k-item").addClass("k-state-disabled");
    }


    On a side note, if the user should not hide a particular column, probably there is a reason why he wouldn't want to do that, so explicitly disabling the checkbox is not required, since the column can be easily displayed back, if hidden by accident.

    Regards,
    Dimo
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top