Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make scrollbar auto enabled or disabled in a Kendo grid?

This is my code for creating the grid:

@{
    if (Model.GenericEntityList.Count > 0)
    {
        @(Html.Kendo().Grid(Model.GenericEntityList).Name(screenNames.ToString()).Columns(
              columns =>
                  {
                      columns.Bound(a => a.ID).Title("<input id='checkAll' type='checkbox' />").ClientTemplate("<input type='checkbox' id=#=genericCheckbox(ID,ViewFlag)#").Width(7);
                      columns.Bound(a => a.Name).Title(screen.ToString() + " Name").Width(93);
                  }
              ).Selectable().Scrollable().DataSource(
                  datasource =>
                  datasource.Ajax().Read(read => read.Action("CompSetHide", "Compset"))
              ).Events(a => a.Change("rowclick")
              )
              .HtmlAttributes(new {style = "height: 185px;"}) 
              )
    }
}

How can I disable and enable the vertical scrollbar that appears inside the kendo grid automatically?

like image 459
user3139423 Avatar asked Dec 31 '13 09:12

user3139423


2 Answers

You can use something like this to show the vertical scroll bar:

$("#grid .k-grid-content").css({
    "overflow-y": "scroll"
});

and this to hide it:

$("#grid .k-grid-content").css({
    "overflow-y": "hidden"
});

where grid is the id of your grid element.

like image 67
Lars Höppner Avatar answered Nov 03 '22 09:11

Lars Höppner


You can add .Scrollable(scrollable => scrollable.Virtual(true))

@{
if (Model.GenericEntityList.Count > 0)
{
    @(Html.Kendo().Grid(Model.GenericEntityList).Name(screenNames.ToString()).Columns(
          columns =>
              {
                  columns.Bound(a => a.ID).Title("<input id='checkAll' type='checkbox' />").ClientTemplate("<input type='checkbox' id=#=genericCheckbox(ID,ViewFlag)#").Width(7);
                  columns.Bound(a => a.Name).Title(screen.ToString() + " Name").Width(93);
              }
          )
.Selectable()
.Scrollable(scrollable => scrollable.Virtual(true))
.DataSource(
              datasource =>
              datasource.Ajax().Read(read => read.Action("CompSetHide", "Compset"))
          ).Events(a => a.Change("rowclick")
          )
          .HtmlAttributes(new {style = "height: 185px;"}) 
          )
}
}
like image 28
Karthikeyan P Avatar answered Nov 03 '22 10:11

Karthikeyan P