I'm generating a KendoUI Grid using ajax dataSource. The table is generated and by default has no class. To keep it looking uniform with the rest of the site, I'd like to add a class "interactive" to it.
$("#pending_documents").kendoGrid({
dataSource: {
transport: {
read: "/get-data?type=1"
},
schema: {
data: "data",
total: "total"
},
pageSize: 2,
serverPaging: true,
serverFiltering: true,
serverSorting: true,
reorderable: true
},
height: 500,
filterable: {
extra: false
/*
, ui: "datetimepicker" // use Kendo UI DateTimePicker
*/
},
sortable: true,
pageable: {
pageSize: 2 },
columns: [...]
});
});
I know that I can do this using JQuery.addClass()
method, run after the grid is generated, however if there a way of setting it in the grid setup/configuration?
Thanks in advance.
You can add a custom CSS class or style to a column header by using the following ColumnComponent options: headerClass —Specifies the class to be added to the header cell.
Bind data to Kendo Grid by using AJAX Read action method. Change the datasource on change event of any HTML controls. Normally, a developer can bind the data to Grid by using AJAX Read method. This read method is ActionResult method in MVC which will return JSON DataSourceResult & direclty bind the data to Grid.
Fired when the widget is bound to data from its data source. The event handler function context (available via the this keyword) will be set to the widget instance.
I guess you don't have any other choice but to use addClass()
. Can't find anything on their documentation about setting a grid's(not grid column) htmlAttributes
using built-it property in JS. I tried it also with no success. Unless you declare it like this (C#):
@(Html.Kendo().TabStrip()
.Name("TabStrip")
.HtmlAttributes( new { @class = "newclass"})
)
But if you really need it in JS, then you'll have to do it like this:
$("#pending_documents").kendoGrid({
dataSource: {
//code
}
}).addClass("newclass");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With