How to hide column grid

2 Answers 4129 Views
Grid
rooney
Top achievements
Rank 1
rooney asked on 10 Oct 2012, 07:19 AM
how to hide column on table grid, but that column show on form create?

Look at this :
schema: {
    model: {
        id: "Id",
        fields: {
            Id: { type: "number" },
            Column1: { type: "string"},
            Column2: { type: "string" },
        }  
    }
},
.......
columns: [
    {
    field:"Column1",
    title: "Column1",
    },
    {
    field: "Column2",
    title: "Column2",
    },
    { command: [{text:"Edit record", name:"edit"}, {text:"Delete record",name:"destroy"}], title: " ", width: "210px" }
]

So, if like that, columns will be show on table and form create are Column1 and Column2
how to make only Column1 is show in table, but on form create Column1 and Cloumn2 is showed

Thank

2 Answers, 1 is accepted

Sort by
0
Ä m o l
Top achievements
Rank 2
answered on 10 Oct 2012, 10:04 AM
 $("#gridName").find("table th").eq(1).hide();
$("#gridName").find("table td:nth-child(2)").hide();

or simply use
var grid = $("#gridName").data("kendoGrid");
 grid.hideColumn(1);

Peter
Top achievements
Rank 1
commented on 17 Oct 2012, 05:57 PM

I've got a Grid with about 1200 rows.  The render performance is great, especially given how many rows it has.  It's instantiated from a javascript array in the page.
I'm trying to use the columnMenu, with one column hidden initially, but viewable by turning it on in the columnMenu.
After instantiating the Grid, I'm using hideColumn() to hide it, which is unusably slow.
I've tried doing
$("#gridName").find("table th").eq(1).hide();
$("#gridName").find("table td:nth-child(2)").hide();
which is plenty fast, but this leaves the column in the columnMenu "checked", but of course it's not visible to it's out of sync in the user interface.
Any ideas why hideColumn() is so slow and is there a faster way to accomplish what I'm after?

Thanks!
chrisj
Top achievements
Rank 1
commented on 14 Nov 2012, 11:50 PM

@Amol - Thanks your solution works great. 
Zaigham
Top achievements
Rank 1
commented on 05 Mar 2013, 09:57 AM

Thanks amol.. your solution works just fine.. is there any way we can avoid using index in hide column and refer it through column name or something?

I am asking because the column's order in our grid keeps on changing
Dan
Top achievements
Rank 1
commented on 07 Dec 2015, 11:03 PM

The hideColumn() method does not appear to be valid anymore.

I get the following exception when I use Amol's solution:

0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'hideColumn'

 

Dimo
Telerik team
commented on 10 Dec 2015, 04:24 PM

Hi Dan,

The hideColumn() method still exists and is valid. You can test it here:

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#methods-hideColumn

The JavaScript error indicates that the Grid widget reference in your code is not valid - please verify.

http://docs.telerik.com/kendo-ui/intro/installation/events-and-methods

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Hemant
Top achievements
Rank 1
answered on 06 May 2013, 12:24 PM
simply use hidden:true in column ,it works for me
here is my example code:
columns: [
{ field:"job_title", title: "Job Title",width:"80px"},
{ field: "eligibility", title:"Eligibility",width:"100px",hidden:true},
{ field: "job_min_experience", title:"Experience",width:"70px",hidden:true},
{ field: "job_max_experience", title:"Experience",width:"70px"},
{ field: "job_location", title:"Location"},
{ field: "certification", title:"Certification"},
{ field: "key_role", title:"Key Role"},
{ field: "key_responsibility", title:"Key Responsibilities"},
{ field: "skills", title:"Skills" },
{ field: "post_date", title:"Posted ON", filterable:{ 
ui: "datetimepicker" // use Kendo UI DateTimePicker
}
},
{ field: "post_status", title:"Status",width:"60px",editor: barEditor },
{ field: "email_id", title:"Posted By"},

  
                            { command: ["edit", "destroy",{text: "View Post", click: showDetails}], title: " ", width: "90px" }
],
Tags
Grid
Asked by
rooney
Top achievements
Rank 1
Answers by
Ä m o l
Top achievements
Rank 2
Hemant
Top achievements
Rank 1
Share this question
or