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

ReferenceError on Grid with ClientTemplate and Adding Row

3 Answers 243 Views
Grid
This is a migrated thread and some comments may be shown as answers.
GCS
Top achievements
Rank 1
GCS asked on 05 Mar 2014, 04:45 PM

This is a strange problem. I have a grid (code below) that contains a templated column for a drop-down control.  Whenever I run the site via an ip address I get the error.  However, when I access the site with a proper domain (eg, rep.ngkflocal.com), it functions fine. 

For instance, when accessed via the following URL: http://72.73.307.275/Plan/Edit/1342
The following error occurs: Uncaught ReferenceError: CapitalExpenditureType is not defined 

However, when accessed like this via my local IIS web app: http://reppublish.ngkflocal.com/Plan/Edit/1342
I do not get the error, adding the row works fine. 

Both point to the same files. Any ideas? 

My Grid code follows: 

  @(Html.Kendo().Grid<Rep.Models.CapitalExpenditureViewModel>()

                                      .Name("CEGrid")
                                      .Columns(columns =>
                                      {
                                          columns.Bound(c => c.Description);
                                          columns.Bound(c => c.CapitalExpenditureType).ClientTemplate("#=CapitalExpenditureType.Value#").Width(250);
                                          columns.Bound(c => c.Amount);
                                          columns.Bound(c => c.DateCostEstimated).Format("{0:dd/MM/yyyy}");
                                          columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
                                      })
                                      .HtmlAttributes(new { style = "height: 400px;" })
                                      .ToolBar(toolbar => toolbar.Create())
                                      .Editable(editable => editable.Mode(GridEditMode.InLine))
                                      .Sortable()
                                      .Scrollable()
                                      .Resizable(resize => resize.Columns(true))
                                      .Pageable(pageable => pageable
                                          .Refresh(true)
                                          .PageSizes(true)
                                          .ButtonCount(5))
                                      .DataSource(datasource => datasource
                                          .Ajax()
                                          .Model(model =>
                                          {
                                              model.Id(p => p.CapitalExpenditureId);
                                              model.Field(p => p.CapitalExpenditureType).DefaultValue(
                                                  ViewData["defaultcapitalExpenditure"] as Rep.Common.LookupItem);
                                          })
                                          .Create(update => update.Action("CapitalExpenditures_Create", "Plan", new { Id = Model.PlanId }))
                                          .Read(read => read.Action("CapitalExpenditures_Read", "Plan", new { PlanId = Model.PlanId }))
                                          .Update(update => update.Action("CapitalExpenditures_Update", "Plan"))
                                          .Destroy(update => update.Action("CapitalExpenditures_Delete", "Plan"))
                                          .PageSize(50)
                                      )
                                      )

3 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 10 Mar 2014, 06:06 AM
Hi,


I tried to reproduce the problem locally but to no avail – everything is working as expected on our side. Could you please provide runable project where this behavior can be reproduced? This would help us pinpoint the exact reason for this behavior.

Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Kryszal
Top achievements
Rank 1
answered on 14 Aug 2015, 11:20 AM

I have the same problem.

 Column:

columns.Bound(bound => bound.OriginalCulture).ClientTemplate("#: OriginalCulture.Name #");

Grid toolbar:

.ToolBar(toolbar => toolbar.Create())

 Error when I am trying to add new record (Chrome console):

VM5186:3 Uncaught ReferenceError: OriginalCulture is not defined(anonymous function) @ VM5186:3ct.ui.DataBoundWidget.extend._rowsHtml @ kendo.all.min.js:32ct.ui.DataBoundWidget.extend._renderContent @ kendo.all.min.js:32ct.ui.DataBoundWidget.extend.refresh @ kendo.all.min.js:32b.extend.proxy.b.isFunction.i @ jquery.min.js:3i.extend.trigger @ kendo.all.min.js:9ut.extend._process @ kendo.all.min.js:11ut.extend._change @ kendo.all.min.js:11b.extend.proxy.b.isFunction.i @ jquery.min.js:3i.extend.trigger @ kendo.all.min.js:9ut.extend.splice @ kendo.all.min.js:11ut.extend.insert @ kendo.all.min.js:11ct.ui.DataBoundWidget.extend.addRow @ kendo.all.min.js:31(anonymous function) @ kendo.all.min.js:31b.event.dispatch @ jquery.min.js:3b.event.add.v.handle @ jquery.min.js:3

 If I remove the client template from the column it seems to work properly.

0
Kryszal
Top achievements
Rank 1
answered on 14 Aug 2015, 01:09 PM

After analyze this request:

http://www.telerik.com/forums/uncaught-referenceerror-when-trying-to-create-new-record

I found that it is needed to define a default value in a grid helper for the column which is bound to a nested property.

So, in my example will be:

.Model(model =>
        {
            model.Id(id => id.UserId);
            model.Field(field => field.OriginalCulture).DefaultValue(new CultureVM());
        })

Tags
Grid
Asked by
GCS
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Kryszal
Top achievements
Rank 1
Share this question
or