stackoverflow demo: grid set scrollable

by lhoeppner

HTML

<script src="http://cdn.kendostatic.com/2013.2.918/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.default.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.common.min.css">
<div style="width: 90%; height: 400px">
    <table id="grid" style="width: 100%; heigth: 100%"></table>
</div>

JavaScript

var localData = [];

var someBool = true;
var someText = "sometext";
for (var i = 0, max_i = 100; i < max_i; i += 1) {
    if (i > 10) {
        someText = "aText";
    }

    if (i > 20) {
        someBool = false;
    }
    localData.push({
        Id: i,
        StatusText: someText,
        someBool: someBool
    });

    if (i % 3 === 0) {
        someBool = null;
        someText = null;
    } else {
        someBool = !someBool;
        someText = "sometext";
    }
}

var dataSource = new kendo.data.DataSource({
    data: localData,
    schema: {
        model: {
            fields: {
                Id: {
                    type: "number"
                },
                StatusText: {
                    type: "string"
                },
                someBool: {
                    type: "boolean"
                }
            }
        }
    }
});

var grid = $("#grid").kendoGrid({
    dataSource: dataSource,
    scrollable: false,
    height: 500,
    sortable: {
        mode: "multiple"
    },
    filterable: true,
    groupable: true,
    columns: [{
        field: "Id",
        title: "Id",
        filterable: false
    }, {
        field: "StatusText",
        title: "String value"
    }, {
        field: "someBool",
        title: "Boolean value"
    }]
}).data("kendoGrid");

function enableScrolling() {
    console.log("setting scrollable");
    if (!grid.options.scrollable) {
        grid.options.scrollable = true;
        grid._thead();
        grid.refresh();
    }
}

function disableScrolling() {
    console.log("setting not scrollable");
    grid.options.scrollable = false;
    grid.table.unwrap(); // manually remove the wrapper that enables scrolling
}

setTimeout(function () {
    enableScrolling();

    setTimeout(function () {
        disableScrolling();

        setTimeout(function () {
            enableScrolling();

        }, 3000);
    }, 3000);
}, 3000);