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

Generic Columns

4 Answers 80 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.
Frank Michael
Top achievements
Rank 1
Frank Michael asked on 07 Jun 2010, 08:03 PM
I want do to something like this:

Html.Telerik().Grid<TableRowPattern>() 
    .Name(Model.name) 
    .BindTo(Model.rows) 
    .DataBinding(binding=>binding.Server().Select<APatternController>(c=>c.Detail(string.Empty))) 
    .DataKeys(keys=>keys.Add(row=>row.RowKey)) 
    .Columns( cols => { 
        cols.Command(commands => 
        { 
            commands.Select(); 
        }); 
        foreach (var col in Model.headings) 
        { 
         cols.Bound<string>(row=>row.cells[Model.headings.IndexOf(col)]).Title(col); 
        } 
    }) 
    .Pageable() 
    .Sortable() 
    .Filterable() 

However this is not possible, because it is necessary to have an accessor in the cols.Bound(). This implies, that it is always necessary to have a fully typed model. This is of disadvantage in many scenarios. For example to do a table with turnover and balance as rows and varying mixed time periods (weeks, months, quarters, years) as colums, that are calculated at runtime.
So what I need is generic columns.

4 Answers, 1 is accepted

Sort by
0
Michiel Peeters
Top achievements
Rank 1
answered on 08 Jun 2010, 10:00 AM
Well i do not know how telerik handles template classes otherwise you can make use of that? Or that i can implicit make use of template classes in views?

(in vb.net)

For Each object In lstModels
    gridBuilder.Columns(Function(column) column.Bound(Function(model as T) T.<propertyName>).Title(object)?
Next

Something like that? Its an interesting idea what you have lemme see if my thinking is correct :).
0
Frank Michael
Top achievements
Rank 1
answered on 08 Jun 2010, 10:46 AM
Hello Michiel,

template class in .Net? I don't know this concept. In know generic classes - of course.
Like List<Something>.
Do you have a reference?

However first feedback:
I have two future scenarios.
1) Is the scenario I already wrote. Dynamically calculated financial periods as colums. For this, actually I have a big table where the period is one of the keys, and the financial category (turnover, profit) is the second key. I can groupBy and so on. But I think to generate a class for the dynamically generated financial period in this scenario is somewhat strange.
2) User defined Business Objects. For example a User defines a Business Object "VacationPlan". Then he might want to define StartDate, FinishDate, TargetLocation, Hotel, TravelArrangement as members of that. In this case, yes, it may make sense to generate a class.

But I want to solve 1) before I go on to 2).
0
Jason
Top achievements
Rank 1
answered on 18 Aug 2010, 10:30 PM
I would also like to know the solution to this issue. I'm running a financial reporting dashboard with mixed year / month / week / day reports that must be generated via the same grid, so the columns must be generic.

Frank what did you do?

-Jason
0
Frank Michael
Top achievements
Rank 1
answered on 19 Aug 2010, 09:05 AM
I have no solution as of yet.
Tags
Grid
Asked by
Frank Michael
Top achievements
Rank 1
Answers by
Michiel Peeters
Top achievements
Rank 1
Frank Michael
Top achievements
Rank 1
Jason
Top achievements
Rank 1
Share this question
or