using checkbox in RadMultiColumnComboBox to set checkbox value in runtime

3 Answers 137 Views
MultiColumn ComboBox
Stefan
Top achievements
Rank 1
Iron
Stefan asked on 03 May 2022, 05:58 AM

Hi

I have a problem updating the RadMultiColumnComboBox header when I retrieve which rows in the data grid are to be selected from the database.
the lines are selected with the lines that I set to true, but they are not put in the combo box header until I use the drop down function. Can this be solved or what am I doing wrong.

Private Sub FrmTestTelerik_Load(sender As Object, e As EventArgs) Handles Me.Load
        SetCheckStateToActvityTypes()
    End Sub

    Private Sub SetCheckStateToActvityTypes()
        For i As Integer = 0 To RadMultiColumnComboBox1.MultiColumnComboBoxElement.Rows.Count - 1
            Dim item As Object = RadMultiColumnComboBox1.MultiColumnComboBoxElement.Rows(i)
            Dim id As Integer = item.Cells(0).value
            If id = GetSelectetActivityTypeIDFromDB(id) Then
                RadMultiColumnComboBox1.MultiColumnComboBoxElement.Rows(i).Tag = Boolean.TrueString
                RadMultiColumnComboBox1.Refresh()

            End If
        Next
    End Sub

Best Regard

Stefan Håkansson Volvo Cars Sweden

 

3 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 03 May 2022, 09:00 AM

Hello Stefan,

Thank you for the provided code snippet.

My assumption is that you are using a similar approach as the one described in this How to Achieve Checked RadMultiColumnComboBox KB article. In the code snippet, the Tag property of the Rows is set, which I think won't trigger custom logic, if this property is used, to select the row. To better assist you, can you isolate your implementation in a standalone project so that I can take a closer look. 

Regards,
Dinko
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Stefan
Top achievements
Rank 1
Iron
answered on 04 May 2022, 05:11 AM

Hello Dinko

Thanks for support.

I am sending with a project that I did yesterday to explain what I am looking for. When you click on a row in the data grid, the types that belong to the activity must be selected according to what is in the Database. This works well in our code, but what does not work is when you change the row, the combo box's head is not filled with the types that are selected. Can you help me with this?

 

Best Regards Stefan Håkansson Volvo Cars Sweden

0
Dinko | Tech Support Engineer
Telerik team
answered on 05 May 2022, 08:51 AM

Hello Stefan,

Thank you for the provided project.

I need to mention that our RadMultiColumnComboBox control does not support multiple selections out of the box. The approach demonstrated in the Multiple Selection help article is a custom solution and may not work in all scenarios. The purpose of such custom solutions is to give a starting point of how a given scenario could be implemented. Covering all cases will require additional code as in this case, setting the Checked property of the CheckBox will not trigger the selection as the collection is not synced until the drop-down is open and closed. 

To make this work you will need to have access to the SyncCollection() method inside the RadMultiColumnComboBoxSelectionExtender class. You can make it public, create a field holding the extender and call it when the button is clicked.

Dim extender As New RadMultiColumnComboBoxSelectionExtender()
    Private Sub SetSelectedActivityTypeToDataBase(ByVal currentRow As GridViewRowInfo)
        Try
            Dim activityTypeItem As Object = oBalanceActivityTypeCollection.BalanceActivityTypeCollection(currentRow.Cells(0).Value)
            For i As Integer = 0 To activityTypeItem.Count - 1
                If currentRow.Cells(0).Value = activityTypeItem(i).BalanceActivityID Then
                    For j As Integer = 0 To RadMultiColumnComboBox1.MultiColumnComboBoxElement.Rows.Count - 1
                        Dim item As Object = RadMultiColumnComboBox1.MultiColumnComboBoxElement.Rows(j)
                        If item.Cells(0).value = activityTypeItem(i).BalanceActivityTypeID Then
                            RadMultiColumnComboBox1.MultiColumnComboBoxElement.Rows(i).Tag = Boolean.TrueString
                            extender.SyncCollection()
                        End If
                    Next
                End If
            Next
        Catch ex As Exception

        End Try
    End Sub
    Private Sub FillComboBox()
        ' get activity types from database and create a list of object
        oBalanceActivityType = New ConfigActivityTypeManager()

        ' set activity list object to data source
        RadMultiColumnComboBox1.DataSource = oBalanceActivityType.BalanceActivityTypeList
        RadMultiColumnComboBox1.DisplayMember = "ActivityTypeName"
        RadMultiColumnComboBox1.ValueMember = "ActivityTypeID"

        RadMultiColumnComboBox1.Columns("ActivityTypeID").IsVisible = False
        RadMultiColumnComboBox1.Columns("ActivityTypeName").HeaderText = "Aktivitetstypnamn"
        RadMultiColumnComboBox1.Columns("ActivityTypeDescription").HeaderText = "Beskrivning"
        RadMultiColumnComboBox1.Columns("Comment").HeaderText = "Kommentar"
        RadMultiColumnComboBox1.Columns("ProcessType").IsVisible = False

        RadMultiColumnComboBox1.AutoSizeDropDownToBestFit = True
        RadMultiColumnComboBox1.DropDownMinSize = New Size(420, 300)
        RadMultiColumnComboBox1.BestFitColumns()
        extender.AssociatedRadMultiColumnComboBox = RadMultiColumnComboBox1
    End Sub

I will suggest further testing this code and modifying it to cover all your requirements.

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

Stefan
Top achievements
Rank 1
Iron
commented on 05 May 2022, 01:28 PM

Hi Dinko

Thanks for the support.

Your suggestions worked really well.
thanks for the help.

Stefan Håkansson Volvo Cars Sweden

Tags
MultiColumn ComboBox
Asked by
Stefan
Top achievements
Rank 1
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Stefan
Top achievements
Rank 1
Iron
Share this question
or