Kendo-ui-core/grid-autofit-all-columns- At Master - GitHub
Có thể bạn quan tâm
Skip to content You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} telerik / kendo-ui-core Public
- Notifications You must be signed in to change notification settings
- Fork 1.9k
- Star 2.5k
- Code
- Issues 1.1k
- Pull requests 17
- Actions
- Projects 0
- Wiki
- Security
- Insights
Files
masterBreadcrumbs
- kendo-ui-core
- docs
- knowledge-base
Latest commit
History
History159 lines (148 loc) · 3.88 KB masterBreadcrumbs
- kendo-ui-core
- docs
- knowledge-base
File metadata and controls
- Preview
- Code
- Blame
title | description | type | page_title | slug | tags | ticketid | res_type |
---|---|---|---|---|---|---|---|
Automatically Fit Width of Grid Columns to Show All Data | Learn how to automatically fit the width of all Kendo UI Grid columns to show all data. | how-to | Automatically Fit Column Width to Show All Data - Kendo UI for jQuery Data Grid | grid-autofit-all-columns-width | grid, autofit, auto, fit, automatically, columns, width, show, all, data | 1148885 | kb |
Environment
Product | Progress® Kendo UI® Grid for jQuery |
Operating System | All |
Browser | All |
Browser Version | All |
Description
How can I have the columns of a Kendo UI for jQuery Grid automatically fit their width to accommodate their contents?
Solution
- Subscribe to the dataBound event.
- Use the autoFitColumn method.
If you have to only set the checked property of the columns to true, use the dataBound event.
<div id="example"> <div id="grid"></div> <script> $(document).ready(function() { var grid = $("#grid").kendoGrid({ dataSource: { type: "odata", transport: { read: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders" }, schema: { model: { fields: { OrderID: { type: "number" }, ShipCountry: { type: "string" }, ShipCity: { type: "string" }, ShipName: { type: "string" }, OrderDate: { type: "date" }, ShippedDate: { type: "date" } } } }, pageSize: 15 }, height: 550, sortable: true, resizable: true, pageable: true, dataBound: function() { for (var i = 0; i < this.columns.length; i++) { this.autoFitColumn(i); } }, columns: [{ field: "OrderDate", title: "Order Date", format: "{0:MM/dd/yyyy}" }, { field: "ShipCountry", title: "Ship Country" }, { field: "ShipCity", title: "Ship City" }, { field: "ShipName", title: "Ship Name" }, { field: "ShippedDate", title: "Shipped Date", format: "{0:MM/dd/yyyy}" }, { field: "OrderID", title: "ID" }, { field: "OrderDate", title: "Order Date", format: "{0:MM/dd/yyyy}" }, { field: "ShipCountry", title: "Ship Country" }, { field: "ShipCity", title: "Ship City" }, { field: "ShipName", title: "Ship Name" }, { field: "ShippedDate", title: "Shipped Date", format: "{0:MM/dd/yyyy}" }, { field: "OrderID", title: "ID" } ] }); }); </script> </div> <style> #grid>table { table-layout: fixed; } </style>See Also
- API Reference of the autoFitColumn Method
- Appearance of the Grid
- API Reference of the dataBound Event
Từ khóa » Html.kendo().grid Column Width
-
Columns.width - API Reference - Kendo UI Grid - Documentation
-
ASP.NET MVC Data Grid Component Column Widths - Documentation
-
How To Set Column Width To Autofit In Kendo Grid MVC - Stack Overflow
-
Auto Fit Column In Kendo Grid - C# Corner
-
How To Set A Max-width Property To Individual Kendo Grid Columns
-
Kendo Grid Column Width + Scrollable - ITecNote
-
How To Set Width Of The Columns In Percentage | JQuery - EjGrid
-
Kendo Grid Column Width + Scrollable
-
Min Column Width In Kendo Grids - ADocLib
-
Kendo Grid Automatically Fit Column Width Excep...anycodings
-
Kendo Grid With Fixed Column - JSFiddle - Code Playground
-
Enforce Minimum Column Width Grid - Popular Blocks
-
Kendo Grid MVC Wrapper Automatic Column Configuration
-
CSS Grid-template-columns Property - W3Schools