What is the sort expression for dynamic columns that come from a collection?

2 posts, 0 answers
  1. Michael
    Michael avatar
    6 posts
    Member since:
    Jun 2013

    Posted 09 Feb 2018 Link to this post

    Some columns in my grid are being added dynamically; their count and names come from a collection. All items in the grid have the same dynamic columns.
    My data object looks like this:

    class MyDataObject
        int ID;
        string Name;
        List<DynamicColumn> DynamicColumns;
    /// <summary>
    /// Holds a value for a single dynamic column cell
    /// </summary>
    class DynamicColumn
        int DynamicColumnDefinitionId; // points to an item in a global collection that defines the dynamic columns for the whole grid.
        int Value;

    The resulting grid could have these columns:
    | ID | Name | DynamicColummn1 | DynamicColummn2 | ... |

    My question:
    How can I sort by one of the dynamic columns? Can I use a sort expression like "DynamicColumn[i]" ?

  2. Eyup
    Eyup avatar
    3940 posts

    Posted 14 Feb 2018 Link to this post

    Hello Michael,

    Generally, when you are utilizing the AutoGenerateColumns feature of the grid to generate the columns automatically you can use the OnColumnCreated event handler to modify their properties:

    To apply actual sorting, you can use the SortExpressions collection of the MasterTableView:

    You can try doing that during the DataBinding event handler and remove the additional Rebind() at the end of the logic.

    I hope this will prove helpful.

    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top