Filtering and Sorting On Custom Column Type

2 posts, 0 answers
  1. Muds
    Muds avatar
    17 posts
    Member since:
    Jan 2015

    Posted 28 Jan 2015 Link to this post

    Hi All

    We needed a row number column in our radGridView hence we followed a suggestion wherein we create a custom column type like this --

    Public Class RowNumberColumn
        Inherits Telerik.Windows.Controls.GridViewDataColumn

        Public Overrides Function CreateCellElement(ByVal cell As GridViewCell, ByVal dataItem As Object) As FrameworkElement
            MyBase.CreateCellElement(cell, dataItem)

            Dim col = cell.Column
            Dim textBlock1 As TextBlock = cell.Content

            If (textBlock1 Is Nothing) Then
                textBlock1 = New TextBlock()
            End If

            Dim t As IList = DataControl.ItemsSource
            textBlock1.Text = (t.IndexOf(dataItem) + 1).ToString()
     
           Return textBlock1
        End Function
    End Class


    And then use this new column as --

            <reservingUi:RowNumberColumn Header="#" IsFilterable="True" IsSortable="True"/>



    Can you please advise on how to enable column filtering and sorting based on the value in the textBlock ?

    Thanks !

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 29 Jan 2015 Link to this post

    Hello Mudit,

    Only columns that are data bound can be filtered/sorted/grouped. You will need to expose a property in your business object that holds the information about the index of the item. Then you can bind the column directly to that property and you will be able to do data operations on it. Still, please keep in mind that you will need to synchronize that property when sorting/filtering is applied.


    Regards,
    Maya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top