Binding data to radcheckeddropdownlistelement in gridview

3 posts, 0 answers
  1. Ali
    Ali avatar
    15 posts
    Member since:
    Aug 2013

    Posted 31 May 2017 Link to this post

    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. Hristo
    Admin
    Hristo avatar
    1508 posts

    Posted 01 Jun 2017 Link to this post

    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.
  3. Ali
    Ali avatar
    15 posts
    Member since:
    Aug 2013

    Posted 01 Jun 2017 Link to this post

    Thanks for the reply. I check it out.
Back to Top