This is a migrated thread and some comments may be shown as answers.

Dynamic number of columns

2 Answers 150 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Kasper Schou
Top achievements
Rank 1
Kasper Schou asked on 28 Jan 2011, 02:42 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Pavel Pavlov
Telerik team
answered on 31 Jan 2011, 11:36 AM
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>>
0
Kasper Schou
Top achievements
Rank 1
answered on 31 Jan 2011, 02:09 PM
This is just great!

Thank you for the swift reply.

Best regards,
Kasper Schou
Tags
TreeListView
Asked by
Kasper Schou
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Kasper Schou
Top achievements
Rank 1
Share this question
or