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

Unable to wrap the contents in the grid column

3 Answers 74 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.
Narayanarao
Top achievements
Rank 1
Narayanarao asked on 15 Mar 2012, 08:51 AM
Hi telerik team,

I have used width(100) etc, in my telerik  columns.bound within the Column(columns => ) . But the text is not getting wrapped, instead i just expands the grid, which i do not want.

the width has no effect if the text has exceeded the column width.

appreciate help. below is the snippet

@(Html.Telerik().Grid(Model.ListM).Name("MyGrid")
     .DataKeys(keys => keys.Add(o => o.Number))
     .Columns(columns =>
     {
         columns.Bound(o => o.Name).Title("Name").emplate(@<text>
               @Html.ActionLink((string)item.Name, "Details", "Management", new { id = item.Number }, null)
               </text>).Width(100);
         columns.Bound(o => o.City).Title("City").Width(100).Filterable(false);
         columns.Bound(o => o.State).Title("State").Width(100).Filterable(false);
         columns.Bound(o => o.Country).Title("Country").Width(100).Filterable(false);
     })
       .ClientEvents(e => e.OnLoad("customizeTelerikGridFilter"))
       .EnableCustomBinding(true)
       .DataBinding(dataBinding => dataBinding.Server().Select("_GetList", "Management"))
       .Pageable(paging => paging.Style(GridPagerStyles.NextPreviousAndNumeric | GridPagerStyles.PageSizeDropDown)
                               .PageSize((int)ViewBag.RecordsinPage, new int[] { 25, 50, 75, 100 })
                               .Total((int)ViewBag.TotalRecords)
                               .Position(GridPagerPosition.Both))
       .Sortable(sorting => sorting
       .OrderBy(sortOrder => sortOrder.Add(o => o.Name).Ascending()))
       .Filterable()


Best regards,
Anand

3 Answers, 1 is accepted

Sort by
0
Narayanarao
Top achievements
Rank 1
answered on 15 Mar 2012, 09:10 AM
So my requirement, more preciesely is irresepective of what ever content wether it contain spaces or its a very long word with no spaces, the column width must not change and must wrap on to next line.

eg. "United states" must wrap at spaces (default behaviour) ; even "SomeUnknownNameWithAVeryLongNameVeryUnusualOneButRequired" must also wrap within that column width and must not expand the column distorting the table.
0
Petur Subev
Telerik team
answered on 20 Mar 2012, 09:42 AM
Hi Narayanarao,

You have two options here:
  1. You should not set width for one of the columns.
  2. You should set width of the Grid using the HtmlAttributes method.
    i.e.
    .HtmlAttributes(new { style="width:1000px"})

Greetings,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Narayanarao
Top achievements
Rank 1
answered on 21 Mar 2012, 12:48 PM
Hi Petur,

I am unable to get what you mentioned by "You should not set width for one of the columns." please elaborate.

Also the second suggestion does not work.

Best regards,
Tags
Grid
Asked by
Narayanarao
Top achievements
Rank 1
Answers by
Narayanarao
Top achievements
Rank 1
Petur Subev
Telerik team
Share this question
or