I'm trying to set the selected items in RadMultiColumnComboBox ( telerik control ) .
I know that selected item will return the object that is selected. Selected index returns the location in the list as an int.
For that reason I have used Selectedindex property and I got what I need if the SelectionMode = "single" using selectindex :
Unfortunately, this solution does not work for RadMultiColumnComboBox when SelectionMode is multiple,
Is there any solution to get a list of selectedindex???
` md = new PersonController().GetPerson(mdl.id); int index = list.FindIndex(r => r.firstName.Equals(md.firstName)); mycbx.SelectedIndex = index;`
10 Answers, 1 is accepted
Hello Abdechafi,
Thank you for your interest in our RadMultiColumnComboBox control for WPF.
If I have correctly understood your scenario, you want to specify the selected items on load. Basically, the SelectedIndex/SelectedItem will present that last selected item inside the selected items collection in multiple selection mode. You can create custom selection behavior to sync the SelectedItems collection property with a custom collection from your view model.
You can find this solution implemented in the attached project. I hope this project is helpful.
Regards,
Dinko
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products, quickly just got a fresh new look + new and improved content, including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hello Abdechafi,
To avoid any misunderstanding, may I ask you to share your set-up so that I can think of a possible solution. You can share how the control is populated on your side.
I am looking forward to your reply.
Regards,
Dinko
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products, quickly just got a fresh new look + new and improved content, including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hi Abdechafi,
If the MVVM approach is not an option for you, you can use the SelectedItems to get or set the selected items. For example, in the Loaded event of the MCCB, you can add the items you want to be selected to the SelectedItems collection.
private void RadMultiColumnComboBox_Loaded(object sender, RoutedEventArgs e)
{
var vm = this.DataContext as ExampleVM;
var mccb = sender as RadMultiColumnComboBox;
mccb.SelectedItems.Add(vm.AllProducts[0]);
mccb.SelectedItems.Add(vm.AllProducts[1]);
mccb.SelectedItems.Add(vm.AllProducts[2]);
}
You can check the attached project and let me know if this approach works for you.
Regards,
Dinko
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products, quickly just got a fresh new look + new and improved content, including a brand new Blazor course! Check it out at https://learn.telerik.com/.
I have tested this , but unfortunately this second solution does not work for me , however, the itemsource of the RadMultiColumnCombobox that I've use binding an List of objects from database ( using Controllers ) , maybe for that reason , I got only the items selected and displayed on the textbox of the Combobox but not selected in the gridView of the Combobox, could you please suggest a modification in this portion of this Xaml Code?
x:Name="dayscbx" DisplayMemberPath="Total" HorizontalAlignment="Stretch" FontSize="{StaticResource FontSizeLarge}" Grid.Row="5" Grid.Column="2"
FontStyle="Normal" Width="auto" Height="auto" DropDownWidth="330" DropDownHeight="255" telerik:StyleManager.Theme="Office2013" SelectionMode="Multiple" Loaded="dayscbx_Loaded">
<telerik:RadMultiColumnComboBox.ItemsSourceProvider>
<telerik:GridViewItemsSourceProvider x:Name="mygrid" AutoGenerateColumns="False" ItemsSource="{Binding AllProducts}" ColumnWidth="auto" >
<telerik:GridViewItemsSourceProvider.Columns>
<telerik:GridViewDataColumn Header="{DynamicResource Shifts}" IsReadOnly="True" DataMemberBinding="{Binding Column1}" />
<telerik:GridViewDataColumn Header="{DynamicResource Days}" IsReadOnly="True" DataMemberBinding="{Binding Column2}" />
<telerik:GridViewDataColumn Header="" IsReadOnly="True" IsVisible="False" DataMemberBinding="{Binding Total}"/>
</telerik:GridViewItemsSourceProvider.Columns>
</telerik:GridViewItemsSourceProvider>
</telerik:RadMultiColumnComboBox.ItemsSourceProvider>
</telerik:RadMultiColumnComboBox>
<
telerik:RadMultiColumnComboBox
local:MultiColumnComboboxSelectionUtilities.SelectedItems
=
"{Binding ActiveProducts.Products, Mode=TwoWay,NotifyOnSourceUpdated=True}"
MouseLeave
=
"daysdepcbx_MouseLeave"
SelectionChanged
=
"daysdepcbx_SelectionChanged"
Grid.ColumnSpan
=
"2"
Margin
=
"12,0,8,0"
x:Name
=
"dayscbx"
DisplayMemberPath
=
"Total"
HorizontalAlignment
=
"Stretch"
FontSize
=
"{StaticResource FontSizeLarge}"
Grid.Row
=
"5"
Grid.Column
=
"2"
FontStyle
=
"Normal"
Width
=
"auto"
Height
=
"auto"
DropDownWidth
=
"330"
DropDownHeight
=
"255"
telerik:StyleManager.Theme
=
"Office2013"
SelectionMode
=
"Multiple"
Loaded
=
"dayscbx_Loaded"
>
<
telerik:RadMultiColumnComboBox.ItemsSourceProvider
>
<
telerik:GridViewItemsSourceProvider
x:Name
=
"mygrid"
AutoGenerateColumns
=
"False"
ItemsSource
=
"{Binding AllProducts}"
ColumnWidth
=
"auto"
>
<
telerik:GridViewItemsSourceProvider.Columns
>
<
telerik:GridViewDataColumn
Header
=
"{DynamicResource Shifts}"
IsReadOnly
=
"True"
DataMemberBinding
=
"{Binding Column1}"
/>
<
telerik:GridViewDataColumn
Header
=
"{DynamicResource Days}"
IsReadOnly
=
"True"
DataMemberBinding
=
"{Binding Column2}"
/>
<
telerik:GridViewDataColumn
Header
=
""
IsReadOnly
=
"True"
IsVisible
=
"False"
DataMemberBinding
=
"{Binding Total}"
/>
</
telerik:GridViewItemsSourceProvider.Columns
>
</
telerik:GridViewItemsSourceProvider
>
</
telerik:RadMultiColumnComboBox.ItemsSourceProvider
>
</
telerik:RadMultiColumnComboBox
>
Thank you so much , I fixed it now
Hello Abdechafi,
I am happy to hear that you have found a solution for your case. If you have any other questions regarding Telerik controls please, don't hesitate to contact us again by opening a new thread.
Regards,
Dinko
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products, quickly just got a fresh new look + new and improved content, including a brand new Blazor course! Check it out at https://learn.telerik.com/.