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

Radgridview and RadComboBox with checkbox with multi select

9 Answers 790 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jean-Christophe
Top achievements
Rank 1
Jean-Christophe asked on 07 Sep 2020, 08:12 AM

Hello

I need a racombobox with checkbox with multiselect and "select all" option, so I used the example from this thread : https://www.telerik.com/forums/radcombobox-with-checkbox-with-multi-select-(using-mvvm)

It works well, but I need it into a radgridview which could have a scrollbar and in this case I got an excepetion when I use the scroll of the radgridview.

It's fire the event OnSelectedItemsPropertyChanged change and so the sub Transfer is called but as the collection changed the Transfer sub crach.

 

I tried to put the radcombobox into a stack panel in order to prevent firing of event but it doesn't work :(

Here the code :

<telerik:RadGridView Margin="6,10,6,32.96" ShowGroupPanel="False" RowIndicatorVisibility="Collapsed" CanUserFreezeColumns="False" CanUserReorderColumns="False"
                             CanUserResizeColumns="True" CanUserSortColumns="False" CanUserDeleteRows="False" CanUserInsertRows="False" ItemsSource="{Binding Rules}"
                             SelectedItem="{Binding SelectedRule}" IsReadOnly="{Binding OnlyRead}"
                             AutoGenerateColumns="False">
 
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn Header="Jib Geometry" Width="100">
                            <telerik:GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                    <telerik:RadComboBox ItemsSource="{Binding JibGeometryDataContexts}" Margin="5,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center"
                                                 Height="22" AllowMultipleSelection="True" EmptyText="Select jib geometry" Grid.Column="1" IsEditable="False" ItemTemplate="{StaticResource MultiSelectComboTemplate}"
                                                 Style="{StaticResource CheckBoxRadComboBox}" MultipleSelectionBoxTemplate="{StaticResource MultiSelectedBoxTemplate}" DropDownClosed="RadComboBox_DropDownClosed">
                                        <i:Interaction.Behaviors>
                                            <combobox:SelectedItemsBehavior SelectedItems="{Binding SelectedJibGeometryDataContexts}" />
                                        </i:Interaction.Behaviors>
                                    </telerik:RadComboBox>
                                    </StackPanel>
                                </DataTemplate>
                            </telerik:GridViewColumn.CellTemplate>
                        </telerik:GridViewDataColumn>                                             
                        ...
                    </telerik:RadGridView.Columns>
 
                </telerik:RadGridView>

 

crash on :

Public Shared Sub Transfer(ByVal source As IList, ByVal target As IList)
            If source Is Nothing OrElse target Is Nothing Then Return
            target.Clear()
 
            For Each o In source
                target.Add(o)
            Next
        End Sub

 

Do you have any Idea to fix these crashes ?

Thanks

Regards

J-Christophe

9 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 10 Sep 2020, 08:05 AM

Hello Jean-Christophe,

Thank you for the provided code snippets.

I tried replicating the exception with the project Dinko provided in the thread you referenced but was, unfortunately, unable to do so.

Can you please also share what is the type of the exception you observe? If possible, would you find it possible to isolate it in a small sample project so that I can further investigate it at my end and upload it to a storage provider of your choice? Alternatively, you can create a new support ticket and upload the project there.

Thank you in advance for your cooperation on the matter. I will be awaiting your reply.

Regards,
Dilyan Traykov
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

0
Jean-Christophe
Top achievements
Rank 1
answered on 11 Sep 2020, 03:07 PM

Hello 

Thanks for your answer.

I tried to create a new small project but I was unable to replicate the exception into this project.

So I attached the exception caught, and I will try to see what is the difference between the initial project and the small project.

Regards

J-Christophe

 

 

0
Dilyan Traykov
Telerik team
answered on 15 Sep 2020, 10:22 AM

Hello J-Christophe,

Thank you for the provided image.

I'm afraid, however, that without being able to replicate the exception at my end, I'm unable to suggest a viable solution for resolving it.

Please let me know whether you can manage to find the difference between the two projects. I will be awaiting your reply.

Regards,
Dilyan Traykov
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

0
Jean-Christophe
Top achievements
Rank 1
answered on 12 Oct 2020, 02:44 PM

Hello Dilyan

I managed to reproduce the error on a small project.
Just launch the application and scrolldown, the program will crash as my main program.
I understand the fact that when I scroll down, the radcombo which were not visible yet, will be loaded and raise the selectionchanged event, but I didn't find how to fix this crash.

How can I attach this example to my post ? Because the only allowed extensions are for picture.

Thanks

Regards
J-Christophe

0
Dilyan Traykov
Telerik team
answered on 13 Oct 2020, 12:03 PM

Hello J-Christophe,

You can attach the project to a storage provided of your choice and provide a download link. Before sending the link, however, please ensure that the Telerik assemblies are not publicly available i.e., they are removed from the project.

In the meantime, I can suggest applying the following modification to the SelectedItemsBehavior which fixes exceptions caused in some scenarios:

        private void ComboSelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (this.ComboBox.ItemsSource != null)
            {
                this.UnsubscribeFromEvents();
                Transfer(this.ComboBox.SelectedItems, SelectedItems as IList);
                this.SubscribeToEvents();
            }
        }

Please let me know whether doing so resolves your issue. If that is not the case, I will be awaiting the isolated project.

Regards,
Dilyan Traykov
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Jean-Christophe
Top achievements
Rank 1
answered on 13 Oct 2020, 12:56 PM

Hello

I tried the modification you suggested but unfortunately, the exception still exist.

So the code is here : grosfi.ch/f4DYxv5PGdd

Thanks

Regards

J-Christophe EICHENBERGER

0
Accepted
Dilyan Traykov
Telerik team
answered on 15 Oct 2020, 01:53 PM

Hello J-Christophe,

Thank you very much for the provided project. I can confirm that I was able to replicate the issue at my end with it.

It appears that in this particular setup you need to unsubscribe to the following event in the UpdateTransfer method:

        Private Sub UpdateTransfer(ByVal items As Object)
            RemoveHandler Me.ComboBox.SelectionChanged, AddressOf Me.ComboSelectionChanged
            Transfer(TryCast(items, IList), Me.ComboBox.SelectedItems)
            AddHandler Me.ComboBox.SelectionChanged, AddressOf Me.ComboSelectionChanged
        End Sub
Can you please give this modification a try and let me know if it resolves the issue in your project as well?

Regards,
Dilyan Traykov
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Jean-Christophe
Top achievements
Rank 1
answered on 16 Oct 2020, 09:13 AM

Hello Dilyan

Thanks for the answer, everything is working ;-)

Regards.

0
Dilyan Traykov
Telerik team
answered on 16 Oct 2020, 12:49 PM

Hello J-Christophe,

I'm happy to hear that the exception is now resolved. Please let me know in case you come across any other issues or if I can help you in any other way.

Regards,
Dilyan Traykov
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
ComboBox
Asked by
Jean-Christophe
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Jean-Christophe
Top achievements
Rank 1
Share this question
or