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

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

3 Answers 824 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 14 Oct 2013, 08:20 PM
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.

3 Answers, 1 is accepted

Sort by
0
Dave
Top achievements
Rank 1
answered on 14 Oct 2013, 08:55 PM
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)
0
Dimiter Madjarov
Telerik team
answered on 15 Oct 2013, 07:17 AM
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!
0
Dave
Top achievements
Rank 1
answered on 15 Oct 2013, 01:20 PM
Interesting. Well, that works. Thanks.
Tags
Grid
Asked by
Dave
Top achievements
Rank 1
Answers by
Dave
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
Dave
Top achievements
Rank 1
Share this question
or