Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
Sorting Does Not Work on UnboundField Columns
posted

I have a column(long datatype) on my grid that is Unbound and all the others are Bound. When I click on the header of the unbound column, the column reorders itself but is not sorted. On second click on header, nothing happens.

Sorting of all bound columns work perfectly.

I have not written any code for sorting except for enabling sorting behavior.

Do we have to write any additional code for sorting unbound columns?

Parents
  • 625
    posted

    This may help you, it may not. I had an issue with using Template Columns where if I tried sorting by these columns then it would completely clear the grid. The solution I found was to add some code behind for the CoumnSorted event:

    Dim strPrevSortedColumn As String = ""

    If HttpContext.Current.Session("CURRENTSORTEDCOLUMN") IsNot Nothing Then

    strPrevSortedColumn = HttpContext.Current.Session("CURRENTSORTEDCOLUMN")

    End If

    Dim arSortColumn As Array = {"", ""}

    If strPrevSortedColumn <> "" Then

    arSortColumn = strPrevSortedColumn.Split(",")

    End If

    If e.Column.Key.Substring(0, 2) = "tc" Then 'All of my Template Column Keys begind with tc

    e.SortedColumns.Clear()

    If e.Column.Key <> arSortColumn(1) OrElse arSortColumn(0) <> "Asc" Then

    e.SortedColumns.Add(Me.[WebDataGridName].Columns("k" & e.Column.Key.Substring(2)), Infragistics.Web.UI.SortDirection.Ascending)

    strPrevSortedColumn = "Asc"

    Else

    e.SortedColumns.Add(Me.[WebDataGridName].Columns("k" & e.Column.Key.Substring(2)), Infragistics.Web.UI.SortDirection.Descending)

    strPrevSortedColumn = "Desc"

    End If

    Else

    strPrevSortedColumn = "None"

    End If

    strPrevSortedColumn &= "," & e.Column.Key

    HttpContext.Current.Session("CURRENTSORTEDCOLUMN") = strPrevSortedColumn

    [Sub to populate Grid]()

Reply Children