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

[Solved] How many carachters I can fit in a RadComboBox

3 Answers 97 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Dario Zanelli
Top achievements
Rank 1
Dario Zanelli asked on 21 Dec 2009, 03:06 PM
Hi all!
A quick question: I have a text to fit in a radcombobox with a fixed width, let's say to 180px.
Is it possible to know how many characters I can fit, or better, whether I can fit a string?
This because I would like to trunk the string, ending it with '...'.
Any help is really welcome!

Dario Zanelli

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Dec 2009, 09:22 AM
Hello Dario,

You can try out the following code to truncate the text in the combobox and see if it helps.
aspx:
<telerik:RadComboBox ID="RadComboBox1" DataSourceID="SqlDataSource1" DataTextField="ProductName" OnClientSelectedIndexChanged="TextSize" OnClientLoad="TextSize" runat="server">  
</telerik:RadComboBox> 

js:
function TextSize(sender,args) 
    {       
      if(sender.get_text().length>8) 
          sender.set_text(sender.get_text().substring(0,8) + "...");       
        
    } 

Thanks
Princy.
0
Dario Zanelli
Top achievements
Rank 1
answered on 23 Dec 2009, 10:49 AM
Hi Princy,
thanks for your answer.
My question was if I can know whether a string fits or not in a RadComboBox.
At the moment I am trunk it using the function you are suggesting, but I would like not to specify a fixed lenght but automatically detect if trunk it or not.

Dario Zanelli
0
Simon
Telerik team
answered on 23 Dec 2009, 12:47 PM
Hi Dario Zanelli,

You could further extend Princy's suggestion as described in this blog post

Please note that all Skins of RadComboBox except Sitefinity use the following font-family:

"Segoe UI",Arial,sans-serif

whereas the latter - only Arial.

Sincerely yours,
Simon
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox
Asked by
Dario Zanelli
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dario Zanelli
Top achievements
Rank 1
Simon
Telerik team
Share this question
or