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

Grid content shown as undefined after upgrade to .Net core 3.0

1 Answer 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John A
Top achievements
Rank 1
John A asked on 04 Dec 2019, 11:49 PM

Grid content shown as undefined all the cells of the grid after upgrade to .Net core 3.0.

I can see the data sent properly from Controller Action, Please see the attached document.

I was required to change my controller action (as part of .Net core 3.0 upgrade)From: return Json(datatable..ToDataSourceResult(request)); To: return Json(datatable.AsEnumerable().ToDataSourceResult(request));

 

 

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 09 Dec 2019, 04:52 PM

Hello John,

I noticed that this forum thread is a duplicate of another support ticket of yours. I have provided an answer to it already but for your convenience and so others could benefit from this I am posting the answer here as well.

Upgrading to ASP.NET Core 3.0 requires DataTable to be cast to an Enumerable as you have already done. Unfortunately, this changes the response and it needs to be modified. This could be done via schema.data configuration of the dataSource.

The configuration used when the data source loads data items from a remote service (transport) for the grid is AJAX which does not allow configuring a schema. That said it should be modified to Custom transport. Overall the configuration of the datasource can be done like this:

 

.DataSource(dataSource => dataSource
                                    .Custom()
                                    .PageSize(2000)
                                    .Schema(s=>s.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);
                                                }
                                            }
                                        })
                                        .Data(@<text>
                                                function (response) {
                                                    return response.Data[0].Table;
                                                }
                                        </text>)
                                    )
                                    .Transport(t=>t.Read(read => read.Action("Read", "ControllerName")))

 

For better tracking of the case and for faster communication I would suggest we keep the conversation in a single thread.

Let me know if you have any questions.

Regards,
Nikolay
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
John A
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or