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

Nested grid error after deployment

2 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Harper
Top achievements
Rank 1
Harper asked on 22 Jul 2015, 06:23 PM

I have the following code: 

@(Html.Kendo().Grid<CheckinViewModel>()
      .Name("grid_#=SubmissionLineItemId#")
      .Columns(cols =>
          {
              cols.Command(cmd => cmd.Destroy()).Width(100);
              cols.Bound(ci => ci.Id).Hidden();
              cols.ForeignKey(ci => ci.StorageAreaId, (IEnumerable)ViewData["storageAreas"], "Id", "Name").Title("Storage Area");
              cols.Bound(ci => ci.Quantity);
              cols.Bound(ci => ci.Bags);
              cols.Bound(ci => ci.Buckets);
              cols.Bound(ci => ci.Jars);
          })
          .ToolBar(tb =>
          {
              tb.Create().Text("Add Checkin");
              tb.Save();
          })
      .Editable(ed => ed.Mode(GridEditMode.InCell))
      .DataSource(ds => ds.Ajax()
                          .Read(read => read.Action("Get", "Checkins", new { submissionItemId = "#=SubmissionLineItemId#" }))
                          .Update(update => update.Action("Update", "Checkins"))
                          .Create(create => create.Action("Create", "Checkins", new { submissionId = @Model.Id, submissionItemId = "#=SubmissionLineItemId#" }))
                          .Destroy(destroy => destroy.Action("Delete", "Checkins"))
                          .Batch(true)
                          .Model(m =>
                          {
                              m.Id(ci => ci.Id);
                              m.Field(ci => ci.StorageArea).Editable(false);
                          })
                          .Events(ev => ev.RequestEnd("updateSubmissionGrid"))
      )
      .ToClientTemplate())

This all works fine running through Visual Studio (development server). However, when I deploy it to my test server, something (I'm not 100% sure what) causes an error. The message "Uncaught SyntaxError: Unexpected token ILLEGAL" (found in the Console of the Chrome browser tools) appears when I expand a row in the parent grid. Subsequently clicking the "Create" button causes an error on my server-side code, as the IDs ("#=SubmissionLineItemId#") are not substituted. Any idea what could cause this?

2 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 24 Jul 2015, 10:06 AM
Hello Harper,


From the provided information it's not clear for us what is the exact reason for current behavior - could you please provide runable example where the issue can be reproduced? This would help us pinpoint the exact reason for current 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
Tony
Top achievements
Rank 1
answered on 06 Jun 2016, 01:57 PM

Harper,

Your post is over a year old, so you may have moved on. I had similar symptoms and found that the response returned from the ToClientTemplate method was adding an extra "\n" in the <script> tag for the child grid when it had an editable ForeignKey column. I think it may have something to do with how Telerik encodes the script definition along with the validation for the resulting dropdown list. I was able to work around this by appending:

.ToHtmlString().Replace("u003e\\n\\u003c", "u003e\\u003c")

to your Kendo Grid definition. You will then need to wrap the entire call with @Html.Raw()

The final result should looks something like this:

@Html.Raw(Html.Kendo().Grid<CheckinViewModel>()
      .Name("grid_#=SubmissionLineItemId#")
      .Columns(cols =>
          {
              cols.Command(cmd => cmd.Destroy()).Width(100);
              cols.Bound(ci => ci.Id).Hidden();
              cols.ForeignKey(ci => ci.StorageAreaId, (IEnumerable)ViewData["storageAreas"], "Id", "Name").Title("Storage Area");
              cols.Bound(ci => ci.Quantity);
              cols.Bound(ci => ci.Bags);
              cols.Bound(ci => ci.Buckets);
              cols.Bound(ci => ci.Jars);
          })
          .ToolBar(tb =>
          {
              tb.Create().Text("Add Checkin");
              tb.Save();
          })
      .Editable(ed => ed.Mode(GridEditMode.InCell))
      .DataSource(ds => ds.Ajax()
                          .Read(read => read.Action("Get", "Checkins", new { submissionItemId = "#=SubmissionLineItemId#" }))
                          .Update(update => update.Action("Update", "Checkins"))
                          .Create(create => create.Action("Create", "Checkins", new { submissionId = @Model.Id, submissionItemId = "#=SubmissionLineItemId#" }))
                          .Destroy(destroy => destroy.Action("Delete", "Checkins"))
                          .Batch(true)
                          .Model(m =>
                          {
                              m.Id(ci => ci.Id);
                              m.Field(ci => ci.StorageArea).Editable(false);
                          })
                          .Events(ev => ev.RequestEnd("updateSubmissionGrid"))
      )
      .ToClientTemplate().ToHtmlString().Replace("u003e\\n\\u003c", "u003e\\u003c"))

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