Reputation: 221
I have a kendo grid.I am binding data source with a List (C#).Generate 50 columns.I want to have my Grid every column with fixed width.Like width 150 px.How could I set default Column width for my grid ?
$("#detailsRevenueGrid").kendoGrid({
dataSource: {
transport: {
read: {
url: "GetDetailsRevenueReportData",
type: "POST",
contentType: "application/json",
dataType: "json"
},
parameterMap: function (data, operation) {
if (operation != "read") {
return kendo.stringify(data.models);
}
}
},
serverPaging: false,
pageSize: 10,
batch: true,
error: function (e) {
alert(e.errors + "grid");
}
},
pageable: {
refresh: true,
pageSizes: true
},
sortable: true,
scrollable:true,
autoBind: false,
resizable: true
});
Upvotes: 1
Views: 3953
Reputation: 7346
Check out the Kendo grid documentation here for that. To do it, you have to define every column that you want in the grid. Here is their example (in case the link breaks later) with a couple of modifications:
<div id="grid"></div>
<script>
$("#grid").kendoGrid({
columns: [
{ field: "name", width: "200px", title: "Name" },
{ field: "age", width: 75, title: "Age" }
],
dataSource: [
{ name: "Jane Doe", age: 30 },
{ name: "John Doe", age: 33 }
]
});
</script>
field
is the name of the property in the data object you are binding to the grid. You can also set the title, the width, and a number of other options described in the docs.
Update
After seeing your comment, I think you can do what you want with a CSS style:
#grid col, #grid td, #grid th {
width: 150px;
}
Where #grid
is the ID of your grid container div. Make sure to remove any width settings from the columns
property as they will most likely override the CSS.
Upvotes: 1