Dynamic number of columns

3 posts, 1 answers
  1. Kasper Schou
    Kasper Schou avatar
    6 posts
    Member since:
    May 2010

    Posted 28 Jan 2011 Link to this post

    Hi Telerik,

    First off I would like to say I just love this control. I asked about this type of control in Q1 2010 and you brougth it soon after. Thanks.

    I now have a task of displaying a dynamic number of columns (booleans), so I can't simply create a view object on which to bind. What is the best approach to achieve this? Is it possible to do this using a datatable as source, and in code behind add the needed columns?

    Also, is it possible to define one or more columns as fixed (not autogenerated) and let the rest dynamic columns be autogenerated?

    Here's a simple overview of the "problem":

    Order    | Customer    | Supplier    | Parameter1    | Parameter2    | ...    | ParameterX
    1             c1                    s1                Y                        N                    Y        N
    2             c1                    s1                N                        Y                    Y        Y
        2a        c2                     s2                Y                        Y                    Y        Y

    The problem is that the number of parameters (and their names) is not available until retrieving this from the datasource, hence I need to create the parameter columns dynamically.
    Important to note though is that the number of parameters will be the same for all orders in the data retrieved.

    Any advice would be appriciated!

    Best regards,
    Kasper Schou
                        
  2. Answer
    Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 31 Jan 2011 Link to this post

    Hi Kasper Schou,

    Thanks for the nice words !
    Now directly on your questions :

    Q: I now have a task of displaying a dynamic number of columns (booleans), so
    A: The DataTable approach should do the trick just fine . RadTreeListView supports binding to a DataTable.

    Q: Also, is it possible to define one or more columns as fixed (not autogenerated) and let the rest dynamic columns be autogenerated?
    A: If you leave the AutoGenerateColumns property to true, RadTreeListView will respect the manually defined columns added by you , and will append the autogenerated columns to the existing ones.

    In case you meet any troubles while implementing these , do not hesitate to drop me a line .

    Kind regards,
    Pavel Pavlov
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Kasper Schou
    Kasper Schou avatar
    6 posts
    Member since:
    May 2010

    Posted 31 Jan 2011 Link to this post

    This is just great!

    Thank you for the swift reply.

    Best regards,
    Kasper Schou
Back to Top