I have a People View that shows People in a Grid and each one has a standard Edit button.
(Guest)Index View
@model IEnumerable<PersonModelBase>
@using Kendo.Mvc.UI
@using SIS.Entities
@using SIS.Web.Models
...
@(Html.Kendo().Grid<PersonModel>()
.Name("peopleGrid")
.Columns(columns =>
{
columns.Bound(p => p.ID).Hidden();
columns.Bound(p => p.FullName)
.HeaderTemplate("Name <input type='text' id='fullname' />")
.Width(230);
columns.Bound(p => p.DOB)
.Format("{0: yyyy-MM-dd}")
.HeaderTemplate("Date of Birth");
// Define command columns
columns.Command(commands =>
{
commands.Edit();
})
.Width(100);
})
//.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Editable(editable => editable
.Mode(GridEditMode.PopUp)
.DisplayDeleteConfirmation(true)
.TemplateName("_AddEditPerson"))
The Edit button goes to the _AddEditPerson Partial View. The PersonModel is successfully passed through with properties within the Model being displayed, including the ID (for debug purposes).
_AddEditPerson Partial View
@model SIS.Web.Models.PersonModel
@using SIS.Web.Models
@using Kendo.Mvc.UI
…
display of ID from Model works fine
@* ID *@
<div class="form-group">
<label for="ID" class="col-sm-2 control-label">ID</label>
<div class="col-sm-10">
@Html.EditorFor(model => model.ID)
</div>
</div>
…
but use of Model to pass through to Grid in TabStrip View does not
@(Html.Kendo().TabStrip()
.Name("bottom-tabstrip")
.Items(tabstrip =>
{
tabstrip.Add().Text("Notes")
.Selected(true)
.Content(
@<text>
<div id="notesGrid" class="form-horizontal">
@*ToDo*@
@Html.Partial("Partials/_NotesGrid", Model.ID)
</div>
</text>);
The _AddEditPerson Partial View then calls some other partial views (e.g. see below) to show Grids for that Person within various tabs.
The issue is that when I try to pass through the ID (of the Person) through to those partials so that they can list items for that person, its null. In fact the whole Model can be seen to be Null when I debug it. If I hard card the ID being passed through it works, so its not an issue in getting it from the AddEdit to the Partial but in using model data for passing through.
What am I missing?
Thanks,
Chris.
_NotesGrid View
@model int
@using Kendo.Mvc.UI
@using ShilohIS.Web.Models
@(Html.Kendo().Grid<NoteModel>()
.Name("notesgrid")
...
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("ReadRegarding", "Notes", new { id = Model }))
.Create(create => create.Action("Create", "Notes"))
.Update(update => update.Action(/* action */"Update", /* controller */ "Notes"))
.Model(model =>
{
model.Id(note => note.ID);
// Guest id
model.Field(note => note.RegardingID).DefaultValue(Model);
// Status
model.Field(note => note.Status).DefaultValue(new SelectListItem());
(Guest)Index View
@model IEnumerable<PersonModelBase>
@using Kendo.Mvc.UI
@using SIS.Entities
@using SIS.Web.Models
...
@(Html.Kendo().Grid<PersonModel>()
.Name("peopleGrid")
.Columns(columns =>
{
columns.Bound(p => p.ID).Hidden();
columns.Bound(p => p.FullName)
.HeaderTemplate("Name <input type='text' id='fullname' />")
.Width(230);
columns.Bound(p => p.DOB)
.Format("{0: yyyy-MM-dd}")
.HeaderTemplate("Date of Birth");
// Define command columns
columns.Command(commands =>
{
commands.Edit();
})
.Width(100);
})
//.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Editable(editable => editable
.Mode(GridEditMode.PopUp)
.DisplayDeleteConfirmation(true)
.TemplateName("_AddEditPerson"))
The Edit button goes to the _AddEditPerson Partial View. The PersonModel is successfully passed through with properties within the Model being displayed, including the ID (for debug purposes).
_AddEditPerson Partial View
@model SIS.Web.Models.PersonModel
@using SIS.Web.Models
@using Kendo.Mvc.UI
…
display of ID from Model works fine
@* ID *@
<div class="form-group">
<label for="ID" class="col-sm-2 control-label">ID</label>
<div class="col-sm-10">
@Html.EditorFor(model => model.ID)
</div>
</div>
…
but use of Model to pass through to Grid in TabStrip View does not
@(Html.Kendo().TabStrip()
.Name("bottom-tabstrip")
.Items(tabstrip =>
{
tabstrip.Add().Text("Notes")
.Selected(true)
.Content(
@<text>
<div id="notesGrid" class="form-horizontal">
@*ToDo*@
@Html.Partial("Partials/_NotesGrid", Model.ID)
</div>
</text>);
The _AddEditPerson Partial View then calls some other partial views (e.g. see below) to show Grids for that Person within various tabs.
The issue is that when I try to pass through the ID (of the Person) through to those partials so that they can list items for that person, its null. In fact the whole Model can be seen to be Null when I debug it. If I hard card the ID being passed through it works, so its not an issue in getting it from the AddEdit to the Partial but in using model data for passing through.
What am I missing?
Thanks,
Chris.
_NotesGrid View
@model int
@using Kendo.Mvc.UI
@using ShilohIS.Web.Models
@(Html.Kendo().Grid<NoteModel>()
.Name("notesgrid")
...
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("ReadRegarding", "Notes", new { id = Model }))
.Create(create => create.Action("Create", "Notes"))
.Update(update => update.Action(/* action */"Update", /* controller */ "Notes"))
.Model(model =>
{
model.Id(note => note.ID);
// Guest id
model.Field(note => note.RegardingID).DefaultValue(Model);
// Status
model.Field(note => note.Status).DefaultValue(new SelectListItem());