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
5 Answers, 1 is accepted
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
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
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
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
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