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

Grid : Build columns form model collection

2 Answers 100 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.
jerome
Top achievements
Rank 1
jerome asked on 15 Sep 2010, 10:02 AM
Hello,

I have this Model :
public class TestModel
{
    public class Def1Ligne
    {
        public string Name { get; set; }
        public int Id { get; set; }
        public bool Activated { get; set; }
        public List<Test> Col{ get; set; }
    }
  
    public class Test
    {
        public string Name { get; set; }
        public bool Activated { get; set; }
    }
}

I want to Build my telerik Grik and add all the columns from the collection "Test"
All row have the same number of collection "Test", the name is the same and Activated change

Here the grid :
<%: Html.Telerik().Grid<TestModel>((IEnumerable<TestModel >)Model)
    .Name("resultsGrid")
    .Columns(columns =>
    {
        columns.Bound(u => u.Name).Width(50).HtmlAttributes(new { style = "text-align:left" })
            .Title("Name");
        columns.Bound(o => o.PageActivated).ClientTemplate("<input type='checkbox' name='PageChecked' value='<#= BlocID #>' />")
            .Title("Activated")
            .Width(50)
            .HtmlAttributes(new { style = "text-align:center" });
        for (int j = 0; j < Model.Col.Count(); j++)
        {
            string sNomCol = Model.Col[j].Name ;
  
            columns.Bound(o => o.Model.Col[j].Activated).ClientTemplate("<input type='checkbox' name='FeatCked' value='<#= ID #>' />")
                .Title(sNomCol)
                .Width(50)
                .HtmlAttributes(new { style = "text-align:center" });
        }
    })
    .Scrollable()
    .Footer(true)
%>

Is it possible ??
How to link the build columns??

Excuse my poor english

Thanks for help

2 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 15 Sep 2010, 11:37 AM
Hi,

I've used the newly introduced feature of setting columns from Controller. I think you need the same thing. Check this online example.

Regards,
Peter.
0
jerome
Top achievements
Rank 1
answered on 15 Sep 2010, 12:00 PM
Thanks for your answer

I had seen this demo

I arrive to build the Columns but how to bind them ? how to bind a field of my collection "Col" to Columns?

Thx
Tags
Grid
Asked by
jerome
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
jerome
Top achievements
Rank 1
Share this question
or