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

Grid Hierarchy

4 Answers 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Виталий
Top achievements
Rank 1
Виталий asked on 03 Aug 2015, 02:27 AM

Hi.

i've grid, like in your example - http://demos.telerik.com/aspnet-mvc/grid/hierarchy.

but there'is two moments:

1. child grid with some foreign key columns (it's work without #2)

2. child grid is editable (it's work without #1)

if 1 and 2 instead, then in chrome browser's console Uncaught SyntaxError: Unexpected token ILLEGAL

Is It Posible to work with #1 and #2 ?

4 Answers, 1 is accepted

Sort by
0
Виталий
Top achievements
Rank 1
answered on 03 Aug 2015, 07:28 AM
@{Html.Kendo().Window()
      .Name("DriftingLogBook")
      .Title("Журнал")
      .Draggable()
      .Resizable()
      .Width(800)
      .Height(400)
      .Pinned()
 
      .Content(
 
      Html.Kendo().Grid<OperReport.Models.DTO.DTOLogBook>()
    .Name("logBookGrid")
    .Columns(columns =>
    {
        columns.Bound(f => f.DocumentDate).Format("{0:dd.MM.yyyy}");
        columns.ForeignKey(p => p.SubUnitId, (System.Collections.IEnumerable)ViewData["subUnits"], "Id", "Name");
        columns.ForeignKey(p => p.DocumentTypeId, (System.Collections.IEnumerable)ViewData["ddTypes"], "Id", "Name");
 
    })
    .ToolBar(t =>
    {
        t.Template(
            @<div>
                <div class="c-tools">
                    <label>  Документ: </label>
                    @(Html.Kendo().DropDownList()
                        .Name("logBookDocumentList")
                            //.Events(e => e.Change("ReadMonthData"))
                        .BindTo(new List<string> {
                            "Добыча",
                            "Проходка"
                        })
                    )
                    <label> Интервал от: </label>
                    @(Html.Kendo().DatePicker()
                        .Name("logBookDateStart")
                        .Events(e => e.Change("ReadLogBookData"))
                        .Value(DateTime.Today)
                        .Format("d")
                    )
                    <label> до: </label>
                    @(Html.Kendo().DatePicker()
                        .Name("logBookDateEnd")
                        .Events(e => e.Change("ReadLogBookData"))
                        .Value(DateTime.Today)
                        .Format("d")
                    )
                </div>
            </div>
);
 
    })             
    //.Pageable().Sortable().Filterable()
    .DataSource(source => source.Ajax()
            .Model(model =>
            {
                model.Id(e => e.Id);
                model.Field(e => e.Id).Editable(false);
            })
        //.Events(events => events.Error("error_handler"))
                .Read(read => read.Action("LogBook_Read", "Drifting").Data("filterLogData"))
           )
    .ClientDetailTemplateId("logBookDrifting")
    .ToHtmlString()
 
      ).Render();
}
<script id="logBookDrifting" type="text/kendo">
 
    @(Html.Kendo().Grid<OperReport.Models.DTO.DTODailyDrifting>()
        .Name("Orders_#=Id#")
        .Columns(columns =>
        {
            columns.ForeignKey(pi => pi.BrigadeId, (System.Collections.IEnumerable)ViewData["brigadies"], "Id", "Name");
            columns.Bound(pi => pi.Value);
            columns.Command(command =>
            {
                command.Edit();
                 
            });
        })
        .ToolBar(tools => tools.Create())
        .Pageable().Sortable().Filterable()
        .DataSource(source => source.Ajax()
            .Model(model =>
                    {
                        model.Id(o => o.Id);
                        model.Field(o => o.Id).Editable(false);
                    })
                .Read(rd => rd.Action("Document_Read", "Drifting", new
                {
                    ddtype = "#= DocumentTypeId #",
                    subunitid = "#= SubUnitId #"
                }).Data("filterLogData"))
 
                .Update(update => update.Action("Document_Update", "Drifting").Data("ValidateData"))
                .Create(create => create.Action("Document_Create", "Drifting").Data("ValidateData"))
            )
        //.ClientDetailTemplateId("OrderDetailsTemplate")
        .ToClientTemplate()
    )
 
</script>
0
Boyan Dimitrov
Telerik team
answered on 05 Aug 2015, 07:50 AM

Hello Виталий,

Both parent and child grids are completely separate grids, so using ForeignKey column and editing functionality should not be a problem. 

I am attaching a sample project with client hierarchy scenario with ForeignKey column and editing functionality enabled. 

 

Regards,
Boyan Dimitrov
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Виталий
Top achievements
Rank 1
answered on 06 Aug 2015, 01:20 AM
Thanks. i think that problem not in view, because i put my view code and controller code in other project - it's work
0
Boyan Dimitrov
Telerik team
answered on 07 Aug 2015, 12:57 PM

Hello Виталий,

 

I am glad to hear that you have solved the problem. 

 

Regards,
Boyan Dimitrov
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Виталий
Top achievements
Rank 1
Answers by
Виталий
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or