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

Hide Row

4 Answers 2157 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 22 May 2012, 02:32 PM
Is it possible to hide a row (or a set of rows) in a grid?

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 25 May 2012, 08:29 AM
Hi Simon,

 This should be possible using the jQuery hide method:

var grid = $("#grid").kendoGrid();
 
grid.tbody.find("tr:first").hide(); // hides the first row

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
ptw
Top achievements
Rank 1
answered on 20 Nov 2016, 11:37 AM

Just in case it helps someone else ...

1.var grid = $('#grid').data('kendoGrid');
2.var items = grid.dataSource.view();
3.for (var i = 0; i < items.length; i++) {
4.    if (items[i].Type == "Sales") {
5.        var $row = $('#grid').find("[data-uid='"+items[i].uid+"']"); // find grid row by uid
6.        $row.hide();
7.    }
8.}

[Adapted from Alexander Popov's (ASP.NET) post: http://www.telerik.com/forums/how-to-hide-a-specific-row-in-kendo-ui-grid#ubk1WdVMoEOFgVwOyCykMw ]

0
ptw
Top achievements
Rank 1
answered on 20 Nov 2016, 12:07 PM

A refinement ... this gets nice the row/alt-row styling too ...

- Paul

01.var grid = $('#grid').data('kendoGrid');
02.var items = grid.dataSource.view();
03.var altRow = false; // keep track of alt row for applying/removing k-alt class
04.for (var i = 0; i < items.length; i++) {
05.    var $row = $('#grid').find("[data-uid='"+items[i].uid+"']"); // find grid row by uid
06.    if (items[i].Type == "Sales") { // hide this row ...
07.        $row.hide();
08.    } else { // (This is a row that is not being hidden)
09.        if (altRow) {
10.            $row.addClass("k-alt"); // add alt row class
11.        } else {
12.            $row.removeClass("k-alt"); // remove alt row class (just in case class exists)
13.        }
14.        altRow = !altRow; // update altRow
15.    }
16.}
0
Terrina
Top achievements
Rank 1
answered on 26 Apr 2017, 09:06 PM
Thank you, this helped me out with a problem I was having!
Tags
Grid
Asked by
Simon
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
ptw
Top achievements
Rank 1
Terrina
Top achievements
Rank 1
Share this question
or