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

[Solved] Binding columns for an array in my model

1 Answer 38 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jonathan
Top achievements
Rank 1
Jonathan asked on 12 Jan 2011, 03:17 PM
I want to create a Grid from a model that has a member field that's an array of int's (int[]) and bind each element of the array to a different column that is sortable/groupable/filterable.  Is there a way to easily do this?

Ideally it would look something like this:

Html.Telerik().Grid(Model)
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(o => o.OrderID).Width(100);
            columns.Bound(o => o.ContactName).Width(200);
            columns.Bound(o => o.ShipAddress);
            columns.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(120);
            columns.Bound(o => o.ArrayField[0]).Title("Something");
            columns.Bound(o => o.ArrayField[1]).Title("Something2");
        })

Thanks in advance!

FWI, this currently throws an error about not being able to extract the Member information from the expression.

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 12 Jan 2011, 03:21 PM
Hi Jonathan,

 Indeed bound columns currently require a member expression (field or property access). You can use template columns instead however then you will lose sorting and grouping. I am afraid that we cannot easily add support for indexing expressions in the bound columns.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or