Rad grid line-break in the items.

6 posts, 1 answers
  1. Saquib
    Saquib avatar
    18 posts
    Member since:
    Aug 2011

    Posted 29 Dec 2011 Link to this post

    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.
  2. Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 03 Jan 2012 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Saquib
    Saquib avatar
    18 posts
    Member since:
    Aug 2011

    Posted 03 Jan 2012 Link to this post

    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.
  5. Answer
    Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 04 Jan 2012 Link to this post

    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
  6. Saquib
    Saquib avatar
    18 posts
    Member since:
    Aug 2011

    Posted 04 Jan 2012 Link to this post

    Thanks for all your help. I appreciate it.. It does work.
  7. Saquib
    Saquib avatar
    18 posts
    Member since:
    Aug 2011

    Posted 04 Jan 2012 Link to this post

    Hey Andrey,

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

    Thanks
    Saquib.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017