Auto size column

1 Answer 9 Views
Grid
Ednaldo
Top achievements
Rank 1
Ednaldo asked on 05 May 2022, 02:05 PM
Hello, do you have any column properties where the size is automatic?
In the example below I set the fixed size to 130px, the more accurate the size is automatic, according to the cell content.

getGridSettings: function () {       
        var settings = {
            excel: {
                allPages: true
            },
            dataSource: GridAdmissionTrackerPublic.getGridDataSource(),
            navigatable: false,
            editable: true,
            sortable: true,
            scrollable: true,
            filterable: true,
            selectable: true,
            persistSelection: true,
            resizable: true,
            height: $(window).height() - 207,
            noRecords: {
                template: function (e) {
                    return "No items to display";
                }
            },
            pageable: {
                pageSizes: [30, 50, 100, 'All'],
                refresh: true
            },
            columns: [
                {
                    field: "StudentId",
                    title: "ID",
                    locked: true,
                    lockable: false,
                    resizable: true,
                    width: 130,
                    overflow: true,
                    minwidth: "100px",
                    minResizableWidth: 70,

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 10 May 2022, 06:33 AM

Hello Ednaldo,

If you omit the width property for all columns they will automatically fit within the table container.

Another option is to use the autoFitColumn() or autoFitColumns() methods which will apply the minimum possible width for the specified column or all so that all text fits without wrapping. Here is an article with a runnable example demonstrating this: 

https://docs.telerik.com/kendo-ui/knowledge-base/grid-autofit-all-columns-width

Hope this helps.

Regards,
Nikolay
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Ednaldo
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or