Hide Row

5 posts, 0 answers
  1. Simon
    Simon avatar
    166 posts
    Member since:
    Sep 2010

    Posted 22 May 2012 Link to this post

    Is it possible to hide a row (or a set of rows) in a grid?
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 25 May 2012 Link to this post

    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!
  3. ptw
    ptw avatar
    27 posts
    Member since:
    Sep 2015

    Posted 20 Nov 2016 Link to this post

    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 ]

  4. ptw
    ptw avatar
    27 posts
    Member since:
    Sep 2015

    Posted 20 Nov 2016 in reply to ptw Link to this post

    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.}
  5. Terrina
    Terrina avatar
    11 posts
    Member since:
    Mar 2013

    Posted 26 Apr 2017 in reply to ptw Link to this post

    Thank you, this helped me out with a problem I was having!
Back to Top