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

[Solved] Hiding columns clientside

4 Answers 224 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Joan Vilariño
Top achievements
Rank 2
Joan Vilariño asked on 27 May 2010, 02:47 PM
Hello.

I need to show/hide a column in an ajax grid based on the value of a checkbox (i.e. show it when checked, hide it when unchecked)... is there any easy way to do it ?

I mean like.
$(document).ready(function() { 
       $('mycheckbox').change(function (e) { 
            var show = $(this).is(':checked'); 
            $('#myGrid').data('tGrid').whateverINeedToDo(show); 
       }); 
}); 

Thanks!

4 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 27 May 2010, 05:12 PM
Hello Joan VilariƱo,

To hide a column on the client side you need to hide the correspoding <col>, <th> and <td> tags. Here is how the script should look like (for hiding the column at index 0):

$('#Grid colgroup').find('col:eq(0)').hide();

$('#Grid th:eq(0)').hide();

$('#Grid tbody tr').find('td:eq(0)').hide();


Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Joan Vilariño
Top achievements
Rank 2
answered on 28 May 2010, 08:08 AM
Thank you ... it worked

Cheers
0
James Strope
Top achievements
Rank 1
answered on 17 Dec 2010, 06:08 PM
If anyone else had problems with this solution, I found that only the first line (the "col") was necessary.  The other 2 lines caused problems (like hiding additional columns).
0
Jakub
Top achievements
Rank 1
answered on 19 Jan 2011, 01:06 PM
The described solution does not work, hide only header column.
Tags
Grid
Asked by
Joan Vilariño
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Joan Vilariño
Top achievements
Rank 2
James Strope
Top achievements
Rank 1
Jakub
Top achievements
Rank 1
Share this question
or