online

Gets or sets the online state of the data source.

Parameters

value Boolean

The online state - true for online, false for offline.

Returns

Boolean—The current online state - true if online. Otherwise, false.

Example - set the online state

var dataSource = kendo.data.DataSource({
    offlineStorage: "products-offline",
    transport: {
        read: {
            url: "https://demos.telerik.com/kendo-ui/service/products",
            type: "jsonp"
        },
        update: {
            url: "https://demos.telerik.com/kendo-ui/service/products/update",
            dataType: "jsonp"
        },
        parameterMap: function(options, operation) {
            if (operation !== "read" && options.models) {
                return {models: kendo.stringify(options.models)};
            }
        }
    },
    schema: {
        model: {
            id: "ProductID"
        }
    }
});
dataSource.online(false);

Example - get the online state

var dataSource = kendo.data.DataSource({
    offlineStorage: "products-offline",
    transport: {
        read: {
            url: "https://demos.telerik.com/kendo-ui/service/products",
            type: "jsonp"
        },
        update: {
            url: "https://demos.telerik.com/kendo-ui/service/products/update",
            dataType: "jsonp"
        },
        parameterMap: function(options, operation) {
            if (operation !== "read" && options.models) {
                return {models: kendo.stringify(options.models)};
            }
        }
    },
    schema: {
        model: {
            id: "ProductID"
        }
    }
});
dataSource.online(false);
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(dataSource.online()); // displays "false"
In this article