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

Rad grid line-break in the items.

5 Answers 311 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saquib
Top achievements
Rank 1
Saquib asked on 29 Dec 2011, 10:51 PM
Hello,

I am using the below statement to bind a column of rad grid.

dr["Options"] = string.Join("<br />", item.SelectedOptions.Where(q => item.ItemOptions.Select(u => u.FirstOrDefault().Key).Contains(q.Key)).Select(x => string.Format("{0} : {1}", x.Key, x.Value)).ToList());

GridBoundColumn: 
<telerik:GridBoundColumn DataField="Options" UniqueName="Options" HeaderText="<%$ Resources:Options %>"><HeaderStyle Width="113px" /></telerik:GridBoundColumn>

'x.Value' is supposed to be not more than 26 characters. The problem is, if the value is more than 22 or 23 characters, the remaining characters are shrinked out. I cannot increase the width of the column, due to lots of other stuff on the page. All I could think of is to have line-break styling. But I don't know how that is possible. Any help would be appreciated... 

Thank you
Saquib.

5 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 03 Jan 2012, 10:41 AM
Hi Saquib,

You could achieve your goal by modifying the dr["Options"] string, then take the substring from 22 to 26 char, split the original string by the substring return value and then insert  <br/> element between them.

Thus when you pass the string to the header text it will render all characters to the 21 on first row and the others on the second.

Give this approach a try and check whether suits your needs.

Greetings,
Andrey
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Saquib
Top achievements
Rank 1
answered on 03 Jan 2012, 07:36 PM
Hello Andrey,

Thanks for your response. I have tried your solution, but the problem is, if I enter 26 capital letters, then only 17 characters accommodate in first line. If I enter 26 W's less than 17 characters...

It is not consistent with 22 characters. I was hoping that there should be a styling property that takes care of it... Is there not?

Thanks
Saquib.
0
Accepted
Andrey
Telerik team
answered on 04 Jan 2012, 02:34 PM
Hello Saquib,

If you are not using FireFox or Opera you could try to apply the following CSS Class:


.RadGrid
{  
word-break: break-all;
}

Thus you will get the desired behavior but only in IE, Chrome, and Safari. In Opera and FireFox you should use the string split approach.

All the best,
Andrey
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Saquib
Top achievements
Rank 1
answered on 04 Jan 2012, 04:01 PM
Thanks for all your help. I appreciate it.. It does work.
0
Saquib
Top achievements
Rank 1
answered on 04 Jan 2012, 08:32 PM
Hey Andrey,

Found out another better solution. This property works in Mozilla also..  
word-wrap: break-word;

Thanks
Saquib.
Tags
Grid
Asked by
Saquib
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Saquib
Top achievements
Rank 1
Share this question
or