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

How to set selecteditems with selectedindex for RadMultiColumnComboBox

10 Answers 1445 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Abdechafi
Top achievements
Rank 1
Veteran
Abdechafi asked on 14 Dec 2020, 12:57 PM

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

Sort by
0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 17 Dec 2020, 09:16 AM

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/.

0
Abdechafi
Top achievements
Rank 1
Veteran
answered on 23 Dec 2020, 07:54 AM
Thank you for your reply , but your solution does not work for me , However, I didn't have used MVVM as design pattern , for that reason it will not work for me 
0
Dinko | Tech Support Engineer
Telerik team
answered on 25 Dec 2020, 03:16 PM

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/.

0
Abdechafi
Top achievements
Rank 1
Veteran
answered on 04 Feb 2021, 05:19 PM
I tested your project and I have spend hours and hours , but I didn't get what I need , the RadMultiColumnComboBox display the selected items only on the display textbox but in the gridView they are not selected that's was my big problem, I need really a solution for that. Note that I have test your project separated and it works ( it was so complicated ) , could you please send me a sample project?
0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 08 Feb 2021, 10:38 AM

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/.

0
Sahaba
Top achievements
Rank 1
answered on 08 Feb 2021, 11:13 AM

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?

 

 

0
Sahaba
Top achievements
Rank 1
answered on 08 Feb 2021, 11:14 AM
        <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>

<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>
0
Abdechafi
Top achievements
Rank 1
Veteran
answered on 08 Feb 2021, 02:14 PM

Thank you so much , I fixed it now

0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 09 Feb 2021, 12:37 PM

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/.

0
Abdechafi
Top achievements
Rank 1
Veteran
answered on 09 Feb 2021, 01:08 PM
Your solution is worked for me ,thank you again
Tags
General Discussions
Asked by
Abdechafi
Top achievements
Rank 1
Veteran
Answers by
Dinko | Tech Support Engineer
Telerik team
Abdechafi
Top achievements
Rank 1
Veteran
Sahaba
Top achievements
Rank 1
Share this question
or