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

Problem : Kendo Grid Dynamic with PopUp Edit Mode Mode

3 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Florian
Top achievements
Rank 1
Florian asked on 16 Mar 2021, 09:08 PM

Hi,

I tried to use dynamic object with Grid on PopUp Edit Mode, but the popup render the elements of the DataTable instead of the columns. (view attach files).

No problem in inline mode.

How to fix this ?

I use the example here.

https://github.com/telerik/ui-for-aspnet-core-examples/blob/master/Telerik.Examples.Mvc/Telerik.Examples.Mvc/Views/Grid/Dynamic.cshtml

 

Regards.

3 Answers, 1 is accepted

Sort by
0
Florian
Top achievements
Rank 1
answered on 18 Mar 2021, 03:35 PM
Another question, how to refresh the definition of the columns when I change the Datatable ?
0
Angel Petrov
Telerik team
answered on 19 Mar 2021, 01:06 PM

Hi,

The described behavior for the template is actually a bug. I have already logged it into our system and you can monitor our progress on the matter from here. As a workaround you can subscribe to the databound event of the grid and clear the initially serialized template.

C#

@(Html.Kendo().Grid<dynamic>()
    .Name("Grid")
    .Columns(columns =>
    {
        .....
    })
    .Pageable()
    .Sortable()
    .Editable(ed => ed.Mode(GridEditMode.PopUp))
    .Filterable()
    .Events(ev=>ev.DataBound("databound"))
    .Groupable()
        .DataSource(dataSource => dataSource
            .Ajax()
            .Model(model =>
            {
                var id = Model.PrimaryKey[0].ColumnName;
                model.Id(id);
                foreach (System.Data.DataColumn column in Model.Columns)
                {
                    var field = model.Field(column.ColumnName, column.DataType);
                    if (column.ColumnName == id) {
                        field.Editable(false);
                    }

                }
            })
            .Read(read => read.Action("Customers_Read", "Dynamic"))
            .Update(read => read.Action("Customers_Update", "Dynamic"))
    )
)

JavaScript

<script>
    var initial = true;
    function databound(e) {
        if (initial) {
            e.sender.options.editable.template = "";
            initial = false;
        }
    }
</script>

As a token of gratitude for reporting this to us I have updated your account points.

As for altering the columns definition this is possible using the setOptions method.

Regards,
Angel Petrov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Florian
Top achievements
Rank 1
answered on 19 Mar 2021, 03:21 PM

Thanks :)

 

Have a nice day.

Tags
Grid
Asked by
Florian
Top achievements
Rank 1
Answers by
Florian
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or