最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how do i wrap a grid line to the with limit in kendo ui grid - Stack Overflow

programmeradmin1浏览0评论

Here is the sample of kendo grid in mvc I would like to text-wrap the column in the grid. Could anyone please help? I have already tried using the css but still its not working. The line is moving out of the box...

columns.Bound(o => o.SectionClass).Width(100).Title("Class");
                        columns.Bound(o => o.Title).Width(100).HtmlAttributes(new { @class = "txtovflw" });
                        columns.Bound(o => o.Description).Width(100).HtmlAttributes(new { @class = "txtovflw" });
                        columns.Bound(o => o.DueDate).Width(80).Title("Due Date");
                        columns.Template(e => { }).ClientTemplate(
                         "<a onclick=\"ViewHW( '#=data.SectionHomeWorkId#')\" id=\"viewHW\" class=\"view-grid-img grid-view-btn\" title=\"View\" data-id=\"<#= data.SectionHomeWorkId
#>\">View</a>")
                         .Title("View")
                         .Width(50);
                    })

.txtovflw
{
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

Here is the sample of kendo grid in mvc I would like to text-wrap the column in the grid. Could anyone please help? I have already tried using the css but still its not working. The line is moving out of the box...

columns.Bound(o => o.SectionClass).Width(100).Title("Class");
                        columns.Bound(o => o.Title).Width(100).HtmlAttributes(new { @class = "txtovflw" });
                        columns.Bound(o => o.Description).Width(100).HtmlAttributes(new { @class = "txtovflw" });
                        columns.Bound(o => o.DueDate).Width(80).Title("Due Date");
                        columns.Template(e => { }).ClientTemplate(
                         "<a onclick=\"ViewHW( '#=data.SectionHomeWorkId#')\" id=\"viewHW\" class=\"view-grid-img grid-view-btn\" title=\"View\" data-id=\"<#= data.SectionHomeWorkId
#>\">View</a>")
                         .Title("View")
                         .Width(50);
                    })

.txtovflw
{
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}
Share Improve this question edited Oct 2, 2014 at 15:47 Mahib 4,0736 gold badges57 silver badges63 bronze badges asked Aug 27, 2013 at 5:52 Md NadeemMd Nadeem 411 gold badge2 silver badges9 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 2

Try this, it will work:

word-wrap: break-word;

or

word-break: break-all;

You are on the correct track with your .txtovflw class, however make sure that you set your table layout to fixed to prevent your table from overflowing it's container.

.k-grid table {
    table-layout: fixed;
}

You'll particularly run into this problem if one of your columns is, for example, email adresses and you have a long unbroken single string.

Source: http://www.telerik./forums/how-can-i-get-ellipsis-instead-of-wrapping

If you want to keep the column content in the column you need to use white-space: normal

.txtovflw
{
   white-space: normal;
}

But by default kendo normally does that.

To word wrap a single column in the grid, create a CSS class.

.wordWrapGridColumn {
    overflow: visible !important;
    white-space: normal !important;
}

Then add the class to the column using HtmlAttributes.

columns.Bound(a => a.Description).Width(100)
     .HtmlAttributes(new { @class = "wordWrapGridColumn" });

Add the following css to you code, it will be applied to all grid columns and you won't need to add style attribute to individual grid column.

<style>
    .k-grid td {
        word-break: break-all !important;
        word-wrap: break-word !important;
    }
</style>
发布评论

评论列表(0)

  1. 暂无评论