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

[Solved] ignored width

2 Answers 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lorne
Top achievements
Rank 1
Lorne asked on 16 Sep 2011, 09:55 PM

I am trying to maintain a fixed width for each column in my MVC grid, even if the data inside the cell is not fully displayable.  It appears to default to the length of the maximum data in the cell or in the header -- regardless of the width value I put in.  I can put in a width of 1 and it is still using the default width.  How can I override this? 
The templates work.  The Filterable works.  The Sortable works.

@{Html.Telerik().Grid(Model)
.Name("Grid")
.DataKeys(keys=> {keys.Add(c=>c.ApplicationId);
})
.Columns(columns =>
    {
        columns.Template(o =>
           
                @Html.ActionLink("Edit", "NotIndex", new { id = o.ApplicationId, area = "Processing", controller = "AppProcessing" })
            ).Title("Edit");
        columns.Bound(o => o.AccountNumber).Title("Acct #").Width("5");
        columns.Bound(o => o.ApplicationId).Title("AppId").Width(5);
        columns.Bound(o => o.LastName).Title("Name").Width(10);
        columns.Bound(o => o.StartDate).Title("Date").Width(10).Format("{0:MM/dd/yyyy}");
        columns.Bound(o => o.BranchOrDepartment).Title("Branch").Width(10);
        columns.Bound(o => o.Owner).Width(15);
        columns.Bound(o => o.Queue).Width(10);
        columns.Bound(o => o.Processor).Title("Proc").Width(10);
        columns.Bound(o => o.Decisioning).Title("Decision").Width(10);
        columns.Bound(o => o.Status).Width(10);
      
           
    }).Sortable()
      .Filterable()
      .Render()
      ;
 }

 @Html.Telerik().ScriptRegistrar()
 @Html.Telerik().StyleSheetRegistrar().DefaultGroup(group=>group.Add("telerik.common.css")
                                                                .Add("telerik.windows7.css"))

2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 19 Sep 2011, 08:50 AM
Hi Lorne,

By default, table columns expand to accommodate all their content. In order to achieve the desired layout, you either need to enable Grid scrolling with Scrollable() ...

http://demos.telerik.com/aspnet-mvc/grid

... or set a table-layout:fixed style for the component's table element with TableHtmlAttributes().

.TableHtmlAttributes(new { style = "table-layout:fixed;" })

Actually, Grid scrolling triggers fixed table layout, which forces the columns to stay as wide as specified. Content which cannot fit, will either overflow (default) or be clipped, if you set overflow:hidden style for the table cells.

All the best,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Lorne
Top achievements
Rank 1
answered on 19 Sep 2011, 05:23 PM
the TableHtmlAttributes was the magic I was looking for.  Thanks.
Tags
Grid
Asked by
Lorne
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Lorne
Top achievements
Rank 1
Share this question
or