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

Set Selected Item text

4 Answers 130 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rajesh
Top achievements
Rank 1
Rajesh asked on 01 Mar 2011, 02:16 PM
Hello Team ,

 I   have combobox and i bind  it to th emplouyee object collection. Now item template should be like this . it should have a checkbox next to the Employee name . This i have already done

 

 

 

<telerik:RadComboBox Name="cmbList" MinWidth="100" DisplayMemberPath="{Binding ItemCountText}" StaysOpenOnEdit="True" OpenDropDownOnFocus="True" IsFilteringEnabled="True" IsTextSearchEnabled="True" Width="120" Margin="2,2,0,0" IsEditable="True" SelectionChanged="cmbList_SelectionChanged" telerik:TextSearch.TextPath="Name" KeyUp="cmbList_KeyUp" Height="20" >

 


 

 

 

<telerik:RadComboBox.ItemTemplate>

 

 

 

 

<DataTemplate>

 

 

 

 

<StackPanel Orientation="Horizontal">

 

 

 

 

<CheckBox Name="chkItem" Click="chkItem_Click" IsChecked="{Binding isSelected}" />

 

 

 

 

<TextBlock Name="txtbckName" Text="{Binding Name}" Width="100" ToolTipService.ToolTip="{Binding Name}" />

 

 

 

 

 

</StackPanel>

 

 

 

 

</DataTemplate>

 

 

 

 

</telerik:RadComboBox.ItemTemplate>

 

 

 

 

 

</telerik:RadComboBox>

Now when suer types automaticall all the emplyess having name with the alphabet should populate . this also i have done .

but the issue is  user wants like when he check the checkbox , item should get selected and in the text search it should display "1 item selected".. so when user selects a 5 emplyees it should display as "5 itesm selected".

Since i already binded the search property to the "Name" i cannot do this . and in the edit mode selection box item  template won't work.

Could you please provide me the solution as this is very immediate requirement and i am stopped.

Regards,
Phani

4 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 04 Mar 2011, 12:00 PM
Hi Phani,

 
When the RadComboBox is in Edit mode, the text in the textbox will be used as search string for the items. It is not allowed to change the text according to the number of checked items. This is not supported.

Could you please give us more detailed information about your scenario?

Best wishes,
George
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Rajesh
Top achievements
Rank 1
answered on 07 Mar 2011, 05:20 AM
Hello George,

Let me explian my Requirement .

1. I have to display the list of countries in th combobox which should support autocomplete and filter the counteries with the alphabets
    user typed in . ( This  i am able to do ).
2. Display should be  Checkbox  and the country name ( This also i  have done with  Data Template).
3. Now user wants when he checks the checkbox  then  the selected item text should be displayed as the  1 item selected . if he select  another one then 2 itesm selected.
So in general  it should  be "no. of items checked + items selected".
 
 I am finding very typical to do because i already binded the text search path to the Country Name. 

Could you please suggest whether it is possible or not ? 

Regards,
Phani
0
Kjell
Top achievements
Rank 1
answered on 07 Mar 2011, 07:40 PM
Phani... I think the problem is that if you change the text after a checkbox is selected, it will break your filtering (since the text filtered on is not there any more).  It seems like you are using radcombo.text as both an input point (for filtering) and output (showing how many checkboxes are checked), and those two functionalities are going to conflict.

If the filtering only needs to occur once, then I have a possible solution...

* Leave the combobox setup as you have it.
* Lay an invisible textblock over the combo box.
* When a country is checked, show the textblock over the combobox text and put the "x items checked" text in that textblock.

That way the original filtering will stay in place, I guess you could also hide the textblock again if everything gets unchecked.
0
George
Telerik team
answered on 10 Mar 2011, 10:54 AM
Hello,

Kjell is right. You cannot use the text in the RadComboBox for both filtering and for custom output(when you select an item). You could achieve this using other textblock next to the RadComboBox(or above it) to display this text.
 

Regards,
George
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
ComboBox
Asked by
Rajesh
Top achievements
Rank 1
Answers by
George
Telerik team
Rajesh
Top achievements
Rank 1
Kjell
Top achievements
Rank 1
Share this question
or