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

Hierarchy Grid using Local Data and MVC/Razor

0 Answers 243 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tag
Top achievements
Rank 1
Tag asked on 17 Oct 2012, 04:20 PM
Is it even possible to create hierarchy tables using local data with MVC Razor? Doesn't appear so. The examples don't work. I've had no trouble with any of the other Kendo controls until now and I'm pulling my hair out...
    @(Html.Kendo().Grid<TaskDTO>(Model.Tasks)
    .Name("tasksTable")
    .Columns(columns =>
    {
        columns.Bound( p => p.ID ).Width( 300 );
        columns.Bound( p => p.Name );
        columns.Bound( p => p.TaskType );
    })
    .ClientDetailTemplateId( "testTemplate" )
    .Pageable()
    .Sortable()
    .Resizable( resize => resize.Columns( true ) )
    .Events( events => events.DataBound( "dataBound" ) )
)

This all works fine without the client template, but when I add in the ClientDetailTemplateId and it's corresponding script, all the columns in the parent table shift one column to the left. DataBind is NOT being called and in fact the template is never even executed.

I was hoping something like this would work

    <script id="testTemplate" type="text/kendo-templ">
@(Html.Kendo().Grid<CustomFieldDTO>( Model.Tasks.Where( f => f.ID == Guid.Parse( "#=ID#" ) ).FirstOrDefault().CustomFields )
        .Name( "CustomTaskFields_#=ID#" )
        .Columns( columns =>
        {
            columns.Bound( q => q.PropertyID );
            columns.Bound( q => q.FieldName );
            columns.Bound( q => q.Value );
        } )
        .Pageable()
        .Sortable()
        .ToClientTemplate()
)
    </script>

but doesn't appear so.

I got it working almost working using DataSource to the controller but I need to send both the Project and Task IDs and ProjectID is not in the bound data that the template gets. I can't find anyway to pass additional data to the template.

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Tag
Top achievements
Rank 1
Share this question
or