How to control scrollbar option per dataSource size in a kendoGrid control

2 Answers 12 Views
Grid
George
Top achievements
Rank 3
Bronze
Bronze
Iron
George asked on 10 Sep 2025, 06:06 PM | edited on 10 Sep 2025, 06:16 PM

Hi,

Would like to dynamically control whether a grid has a slider control for the roles.

The algorithm /flow would look something like this:

grid is declared and options initialized  within windows.onload or $(document).ready(function() {});

user makes selection to load grid  

data populates the datSource from an API request.

  if(dataSource.length > 10 )
    then let scrollable = true;
  else
scrollable = false;


The idea here is it would dynamically adjust that scrollable option after a certain length threshold would be met.

attached here is how I have my grid set up..also I have the sort and dataBound handlers doing stuff.

Here is inline version of JavaScript / jQuery kendo code that declares and does some initialization:

 $("#myGrid").kendoGrid({
     width: 1400,
     height: 500,
     sortable: {
         mode: "single",
         allowUnsort: false
     },
     resizable: true,
     editable: true,
     scrollable: true,
     columns: modifiedColumns, // Use updated columns
     dataSource: mappingsDS,
     selectable: "multiple, row",

Thanks,

George

2 Answers, 1 is accepted

Sort by
0
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
answered on 11 Sep 2025, 03:36 PM

You can set the scrollable property via options, e.g.

  var grid = $("#myGrid").data("kendoGrid");
  grid.options.scrollable = (data.length > 10);

However, it appears that it needs to be set before the dataSource is set -- if you set it after, either inline or via the dataBound event, it is too late.

This dojo provides an example. In the toggle() function, if you comment out setting scrollable before the dataSource and uncomment setting it after, it doesn't work. Similarly, uncommenting setting it in the dataBound event doesn't work either.

 

0
Neli
Telerik team
answered on 15 Sep 2025, 09:27 AM

Hi George,

Dynamically Controlling the Scrollbar (Scrollable Option) Based on Data Size

The Kendo UI Grid’s scrollable option determines whether a vertical scrollbar appears when the data exceeds the visible area. This property must be set at initialization—changing it after the grid is created does not take effect. Here’s how you can dynamically adjust it based on your data size:

  • Determine Data Size Before Initialization:
    Check your data array size after your API call but before creating the grid. Set the scrollable option accordingly.

  • Example Implementation:

    var data = /* API response */;
    var scrollableOption = data.length > 10;
    
    $("#myGrid").kendoGrid({
        width: 1400,
        height: 500,
        sortable: {
            mode: "single",
            allowUnsort: false
        },
        resizable: true,
        editable: true,
        scrollable: scrollableOption,
        columns: modifiedColumns,
        dataSource: data,
        selectable: "multiple, row"
    });
    
  • Updating Grid After Data Changes:
    If you want to reload the grid with new data and possibly a new scrollable value, destroy the existing grid and re-initialize it:

    $("#myGrid").data("kendoGrid").destroy();
    $("#myGrid").empty();
    
    var newData = /* new API data */;
    var newScrollable = newData.length > 10;
    
    $("#myGrid").kendoGrid({
        width: 1400,
        height: 500,
        sortable: {
            mode: "single",
            allowUnsort: false
        },
        resizable: true,
        editable: true,
        scrollable: newScrollable,
        columns: modifiedColumns,
        dataSource: newData,
        selectable: "multiple, row"
    });
    

You mentioned wanting to control a "slider control for the roles." If you are referring to the vertical scrollbar that appears when scrollable: true, the above approach will handle that. However, if "slider control" refers to a different UI element (such as the Slider or custom control inside the grid), please provide more details about what you need to achieve so I can offer a more targeted solution.

    Regards,
    Neli
    Progress Telerik

    Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

    Tags
    Grid
    Asked by
    George
    Top achievements
    Rank 3
    Bronze
    Bronze
    Iron
    Answers by
    Jay
    Top achievements
    Rank 3
    Bronze
    Iron
    Iron
    Neli
    Telerik team
    Share this question
    or