How can hide/show a Kendo Grid

Rui Martins picture Rui Martins · Sep 19, 2014 · Viewed 13.7k times · Source

So this is my grid and what I need is to have it hidden when the page is rendered and to show it when I click the search Button. Any ideas??

    @Html.WebCore().LinkButton(ButtonType.Zoeken, cssClass: "myZoekenButton") 


    @(Html.Kendo().Grid<AanvragenZoekenViewModel.ZoekResultaat>()
        .Name("Grid")
        .Columns(columns =>
        {
...
            columns.Bound(zoekResultaat => zoekResultaat.Opmerkingomschrijving).ClientTemplate("#= Opmerkingomschrijving#").Hidden(Model.DossierLijst);
        })
...
        .AutoBind(false)
        .DataSource(dataSource => dataSource
            .Ajax()
            .Batch(true)
            .Events(e => e.Error("onErrorhandling"))
            .Model(model =>
            {
            })
            .Read(read => read.Action(MVC.Dashboard.ActionNames.ReadItems, MVC.Dashboard.Name).Data("onReadAdditionalData"))
            .PageSize(500)
        )    
    )

Answer

Krushnakant Ladani picture Krushnakant Ladani · Sep 20, 2014

Kendo grid doesn't have HIDE/SHOW property. You need to do this in JQuery.

At run time, kendo grid will convert it into DIV tag.

you need to hide/show DIV tag in jquery.

(Div id will be name of grid )

Hide grid on page Load

$(document).ready(function() {
   $( "#Grid" ).hide();
});

Show grid on button click

$('#button').click(function(){
  $('#Grid').show();
});