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

Cut txt if it exceeds column's width.

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andi Haviari
Top achievements
Rank 1
Andi Haviari asked on 16 Dec 2010, 03:54 PM
Hello, 

I want to cut the text in my columns if they exceed the column's width (to display them in a tool-tip) .
 My columns are all GridBoundColumns, ive tried to set their width on the WIDTH propriety but it didn't work.

Thanks

1 Answer, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 16 Dec 2010, 09:22 PM
Hello Andi,

Technically it should be doing this automatically since it has "text-overflow:ellipsis" defined on the columns. Setting the width doesn't do anything. The technique I've used is changing those columns into a GridTemplateColumn and then in the ItemTemplate I place div that restricts the height/width and have the content contained in that div. Like so:

<telerik:GridTemplateColumn DataField="Description">
    <ItemTemplate>
        <div style="overflow: hidden; height:50px;" title="<%#DataBinder.Eval(Container.DataItem, "Description") %>">
            <%#DataBinder.Eval(Container.DataItem, "Description") %>
        </div>
    </ItemTemplate>
</telerik:GridTemplateColumn>

You can set the height accordingly, to your needs, depending on how many lines you have visible.

I hope that helps.
Tags
Grid
Asked by
Andi Haviari
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Share this question
or