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

First row expand bug

1 Answer 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saulo
Top achievements
Rank 1
Saulo asked on 10 Nov 2015, 02:40 PM

I have an Hierarchical Grid and a problem appears when the first row is expanded before another row:

If I insert any record to any child grid, it record will be inserted for the first row's parent grid (in database too).

My Grid:

@(Html.Kendo().Grid<AvvaWebApi.Models.DataFilterViewModel>()
                    .Name("grid")
                    .Columns(columns =>
                    {
                        columns
                            .Bound(c => c.Alias)
                            .Title("Nome de identificação")
                            .Width(300);


                        columns.Bound(c => c.Zone)
                            .ClientTemplate("# if (typeof Zone !== 'undefined' && Zone !== null) {# #=Zone.Number# #} else {# N/A #} #")
                            .EditorTemplateName("Zone")
                            .Title("Zona de Alarme")
                            .Filterable(false)
                            .Width(130);

                        columns
                            .Bound(c => c.AlarmType)
                            .ClientTemplate("# if (typeof AlarmType !== 'undefined' && AlarmType !== null) {# #=AlarmType.Text# #} else {# N/A #} #")
                            .EditorTemplateName("AlarmType")
                            .Title("Tipo de Alarme")
                            .Filterable(false);

                        columns
                            .Bound(c => c.OutputText)
                            .Title("Texto de saída");

                        columns
                            .Bound(c => c.DigitalOutput).Title("Saída digital")
                            .EditorTemplateName("Integer")
                            .Width(110)
                            .Filterable(false);

                        columns
                            .Bound(c => c.TurnOnGiroflex)
                            .Title("Ligar Giroflex")
                            .Width(110)
                            .Filterable(false)
                            .ClientTemplate("# if(TurnOnGiroflex) { #&#10004;# } else { #&mdash;# } #");

                        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(250);
                    })
                    .ToolBar(toolbar =>
                    {
                        toolbar.Create();
                    })
                    .Editable(editable => editable.Mode(GridEditMode.InLine))
                    .Pageable()
                    .Filterable()
                    .Scrollable()
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .Model(model => model.Id(p => p.Id))
                        .Model(model => model.Field(p => p.AlarmTypeId).DefaultValue(1))
                        .Model(model => model.Field(p => p.ZoneId).DefaultValue(1))
                        .Read(read => read.Action("DataFilters_Read", "DataFiltersGrid"))
                        .Create(create => create.Action("DataFilters_Create", "DataFiltersGrid"))
                        .Update(update => update.Action("DataFilters_Update", "DataFiltersGrid"))
                        .Destroy(destroy => destroy.Action("DataFilters_Destroy", "DataFiltersGrid"))
                    )
                    .Events(events => events.DataBound("dataBound"))
                    .HtmlAttributes(new { style = "height: 533px;" })
                    .ClientDetailTemplateId("templateConditions"))

 

The template Grid:

 

<script id="templateConditions" type="text/kendo-tmpl">

    @(Html.Kendo().Grid<AvvaWebApi.Models.ConditionViewModel>()
      .Name("gridCondicoes")
      .Columns(columns =>
      {
          columns.Bound(c => c.OrdinalPosition)
            .Title("Ordem de precedência")
            .EditorTemplateName("Integer")
            .Width(100);

          columns.Bound(c => c.LogicOperator)
            .Title("Operador condicional")
            .ClientTemplate("\\# if (typeof LogicOperator !== 'undefined') {\\# \\#=LogicOperator.Text\\# \\#} \\#")
            .EditorTemplateName("LogicOperator")
            .Width(170);

          columns
            .Bound(c => c.Analytic)
            .Title("Onde aconteceu?")
            .ClientTemplate("\\# if (typeof Analytic !== 'undefined') {\\# \\#=Analytic.Alias\\# \\#} \\#")
            .EditorTemplateName("CascadedAnalytic");

          columns.Bound(c => c.EventType)
            .Title("O que aconteceu?")
            .ClientTemplate("\\# if (typeof EventType !== 'undefined') {\\# \\#=EventType.Text\\# \\#} \\#")
            .EditorTemplateName("EventType")
            .Width(250);

          columns.Bound(c => c.SecondsSinceLast)
            .Title("Segundos depois")
            .EditorTemplateName("Integer")
            .Width(100);

          columns.Command(command => { command.Edit(); command.Destroy(); }).Width(250);
      })
      .ToolBar(toolbar =>
      {
          toolbar.Create();
      })
      .Editable(editable => editable.Mode(GridEditMode.InLine))
      .Scrollable()
      .DataSource(dataSource => dataSource
          .Ajax()
          .ServerOperation(false)
          .Sort(sort => sort.Add(x => x.OrdinalPosition).Ascending())
          .Model(model => model.Id(p => p.Id))
          .Model(model => model.Field(p => p.AnalyticId).DefaultValue(1))
          .Model(model => model.Field(p => p.LogicOperatorId).DefaultValue(1))
          .Model(model => model.Field(p => p.EventTypeId).DefaultValue(1))
          .Read(read => read.Action("Conditions_Read", "ConditionsGrid", new { dataFilterId = "#=Id#" }))
          .Create(create => create.Action("Conditions_Create", "ConditionsGrid").Data("onCreateCondition"))
          .Update(update => update.Action("Conditions_Update", "ConditionsGrid"))
          .Destroy(destroy => destroy.Action("Conditions_Destroy", "ConditionsGrid"))
      ).ToClientTemplate()
    )
</script>

 

Anyone had this problem anytime?​

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 12 Nov 2015, 01:36 PM
Hi Saulo,

Most probably happens due to the IDs passed to the child Grids. I am not sure which field exactly depicts the parent item, however I would suggest checking the hardcoded default values for the child Grid's DataSource Model. You can also find a similar example below:

Regards,
Alexander Popov
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
Saulo
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or