This is a migrated thread and some comments may be shown as answers.

Grid dynamic column width issue

4 Answers 1193 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 23 Jul 2015, 10:45 AM

Hi there,

I'm having trouble with a Kendo grid resizing.  Basically, the content is extending beyond the width of my table, when the content should be wrapping instead.  I've added a screenshot to try and display the issue - the 'Description' column should be wrapping but instead isn't and the table content therefore is going beyond the width of the div the table sits in.  Furthermore, using the debug tools in Chrome shows that the table itself is positioned correctly, but it's the th and td cells which are displaying outside of the table area (hopefully the screenshot demonstrates that too).  The code I am using in my view is fairly basic :-

Html.Kendo().Grid((IEnumerable<TEAMSPortalV2.Models.SampleComputedDataViewModel>)ViewData["samples"]) // Bind the grid to the Model property of the view
            .Name("ItemsByRiskSamples")
            .Sortable()
            .Columns(columns =>
            {
                columns.Bound(s => s.BuildingDesignation).Title("Building");
                columns.Bound(s => s.FloorNoConverted).Title("Floor");
                columns.Bound(s => s.RoomDescription).Title("Room");
                columns.Bound(s => s.RegisterItemNo).Title("Item No.");
                columns.Bound(s => s.SampleRef).Title("Sample Ref.").Width(40);
                columns.Bound(s => s.SourceDescription).Title("Description");
                columns.Bound(s => s.AsbestosType);
                columns.Bound(s => s.MaterialAssessmentScoreString).Title("MA Score").Width(40);
                columns.Bound(s => s.PriorityAssessmentScore).Title("PA Score").Width(40);
                columns.Bound(s => s.RiskScore).ClientTemplate("<span bgcol='#= RiskScoreGroupColour#'>#= RiskScoreString#</span>").Width(40);
                columns.Bound(s => s.RecommendedAction).Title("Rec. Action").ClientTemplate("<span bgcol='#= RecommendedActionColour#'>#= RecommendedAction#</span>");
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .ServerOperation(false)
            )
            .Events(e => e.DataBound("itemBackColours"))

I've played around with it and by adding a width property to other columns sometimes rectifies the problem (but not always at smaller resolutions) seemingly randomly.  That said, I don't want to specify column widths - I'd rather let the browser display the content as efficiently as possible as per normal HTML table behaviour.  I also noticed that at wider resolutions it often seems to snap into the correct widths - which seems to suggest thast Bootstrap is involved somehow (my site has got Bootstrap installed).

Please could you assist and give me some suggestions of what I can try to rectify this issue.

Thanks, Mark

4 Answers, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 27 Jul 2015, 12:55 PM
Hi,

The column widths are subject to a number of constraints covered in the documentation.

The specific issue you're having, along with possible solutions, is discussed in the Using a wide non-scrollable Grid section.

I hope this helps.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Mark
Top achievements
Rank 1
answered on 28 Jul 2015, 08:28 AM
Thanks - I've sorted it out now :)
0
Joel
Top achievements
Rank 1
answered on 21 Feb 2018, 03:32 PM
Having a similar issue... can you provide a new link to 'Using a wide non-scrollable Grid' as it is broken, thanks.
0
Stefan
Telerik team
answered on 23 Feb 2018, 07:59 AM
Hello, Joel,

The article was removed from the documentation as all of the width-related specifics were moved in one place.

Please check the following article describing the different behaviors depending on the scenario:

https://docs.telerik.com/kendo-ui/controls/data-management/grid/appearance#width

I hope this is helpful.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Mark
Top achievements
Rank 1
Joel
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or