PDA

View Full Version : [CLOSED] [Razor] TreeGrid in Razor



UnifyEducation
Oct 01, 2012, 8:57 AM
Hi,

I try to build a simple TreeGrid with Razor but it doesn't show the contents like the grid.
Here is my code:



@model dynamic

@{
Layout = null;
}
@Html.X().ResourceManager()
@(Html.X().TreePanel()
.Width(500)
.Height(800)
.UseArrows(true).Collapsible(true).Title("Title")
.RootVisible(false)
.MultiSelect(true)
.SingleExpand(true)
.FolderSort(true)
.Fields(f =>
{
f.Add(Html.X().ModelField().Name("name"));
f.Add(Html.X().ModelField().Name("description"));
})
.ColumnModel(c =>
{
c.Add(Html.X().TreeColumn().DataIndex("name").Text("Name").Sortable(true).Flex(2));
c.Add(Html.X().Column().DataIndex("description").Text("Description").Sortable(true).Flex(3));
})
.Root(r => r.Add(Html.X().Node().Text("Root")
.Children(c=>
{
c.Add(Html.X().Node()
.CustomAttributes(a =>
{
a.Add(new ConfigItem("name", "name1", ParameterMode.Value));
a.Add(new ConfigItem("description", "description1", ParameterMode.Value));
})
.Children(cl =>
{
cl.Add(Html.X().Node().Leaf(true)
.CustomAttributes(a =>
{
a.Add(new ConfigItem("name", "name11", ParameterMode.Value));
a.Add(new ConfigItem("description", "description11", ParameterMode.Value));
}));
cl.Add(Html.X().Node().Leaf(true)
.CustomAttributes(a =>
{
a.Add(new ConfigItem("name", "name12", ParameterMode.Value));
a.Add(new ConfigItem("description", "description12", ParameterMode.Value));
}));
})
);
c.Add(Html.X().Node()
.CustomAttributes(a =>
{
a.Add(new ConfigItem("name", "name2", ParameterMode.Value));
a.Add(new ConfigItem("description", "description2", ParameterMode.Value));
})
.Children(cl =>
{
cl.Add(Html.X().Node().Leaf(true)
.CustomAttributes(a =>
{
a.Add(new ConfigItem("name", "name21", ParameterMode.Value));
a.Add(new ConfigItem("description", "description21", ParameterMode.Value));
}));
cl.Add(Html.X().Node().Leaf(true)
.CustomAttributes(a =>
{
a.Add(new ConfigItem("name", "name22", ParameterMode.Value));
a.Add(new ConfigItem("description", "description22", ParameterMode.Value));
}));
})
);
})
))
)


Could you tell me what is the missing things I need to add to this code?
Thanks in advance,

Vladimir
Oct 01, 2012, 9:03 AM
Instead 'c.Add' in '.ColumnModel(c =>'
you have to use 'c.Columns.Add'

UnifyEducation
Oct 01, 2012, 9:12 AM
Instead 'c.Add' in '.ColumnModel(c =>'
you have to use 'c.Columns.Add'

Thanks for your help. You can mark this as CLOSED