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

Binding data to radcheckeddropdownlistelement in gridview

2 Answers 142 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ali
Top achievements
Rank 1
Ali asked on 31 May 2017, 06:10 PM

Hi Team.

I was able to create custom radcheckeddrowdownlistelement in radgridview, but can figure out how to bind datasource when adding rows since each row with the custom radcheckeddropdownlistelement will different datasouce bind to it. Below is my code:

// Custom checkbox list

Public Class CheckBoxListCellElement
    Inherits GridDataCellElement
    Public Sub New(ByVal column As GridViewColumn, ByVal row As GridRowElement)
        MyBase.New(column, row)
    End Sub
    Private checkBoxListElement As RadCheckedDropDownListElement
    Protected Overrides Sub CreateChildElements()
        MyBase.CreateChildElements()
        checkBoxListElement = New RadCheckedDropDownListElement
        Me.Children.Add(checkBoxListElement)
    End Sub
    Protected Overrides Sub SetContentCore(value As Object)
        If Me.Value IsNot Nothing AndAlso Me.Value IsNot DBNull.Value Then

            Me.checkBoxListElement.Text = Convert.ToString(value)
        End If
    End Sub



    Protected Overrides ReadOnly Property ThemeEffectiveType() As Type
        Get
            Return GetType(GridDataCellElement)
        End Get
    End Property
    Public Overrides Function IsCompatible(data As GridViewColumn, context As Object) As Boolean
        Return TypeOf data Is CheckBoxListColumn AndAlso TypeOf context Is GridDataRowElement
    End Function
End Class
Public Class CheckBoxListColumn
    Inherits GridViewDataColumn
    Public Sub New(ByVal fieldName As String)
        MyBase.New(fieldName)
    End Sub
    Public Overrides Function GetCellType(row As GridViewRowInfo) As Type
        If TypeOf row Is GridViewDataRowInfo Then
            Return GetType(CheckBoxListCellElement)
        End If
        Return MyBase.GetCellType(row)
    End Function
End Class

 

// main form load event with the gridview

 Private Sub QuestionaireForm_Load(sender As Object, e As EventArgs) Handles Me.Load
       
     
        RadGridView1.Rows.Add(data1 to bind to customradcheckboxlist )
        RadGridView1.Rows.Add(data1 to bind to customradcheckboxlist )

    End Sub

 

However, I have seen the article on radgridview editor required for the radcheckeddropdownlist. But want the above code to work.

Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 01 Jun 2017, 07:51 AM
Hello Ali,

Thank you for writing.

You can follow the approach suggested in the following KB resource: Cascading ComboBoxes in RadGridView. You will also need to adjust it according to your local setup and the custom classes you have. At the end, however, you should be able to display different data in the drop down editors for the different rows.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Ali
Top achievements
Rank 1
answered on 01 Jun 2017, 12:19 PM
Thanks for the reply. I check it out.
Tags
General Discussions
Asked by
Ali
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Ali
Top achievements
Rank 1
Share this question
or