Ok, so I have a Kendo grid with InLine editing enabled.
@(Html.Kendo().Grid<DestinationDisplayModel>()
.Name("secondaryDestinationGrid")
.DataSource(dataSource => dataSource.Ajax().ServerOperation(true)
.Read(read => read.Action("RefreshDestinationGrid", "BookTrip"))
.PageSize(20)
.Model(model =>
{
model.Id(ddm => ddm.DestinationId);
model.Field(ddm => ddm.Country);
model.Field(ddm => ddm.ShortArrivalDate);
model.Field(ddm => ddm.ShortDepartureDate);
model.Field(ddm => ddm.TravelDays).Editable(false);
})
.Batch(true)
.Create(create => create.Action("CreateSecondaryDestination", "BookTrip"))
.Update(update => update.Action("EditingCustom_Update", "Grid"))
.Destroy(destroy => destroy.Action("EditingCustom_Destroy", "Grid"))
)
.Columns(columns =>
{
columns.Bound(tdm => tdm.Country);
columns.Bound(tdm => tdm.ShortArrivalDate);
columns.Bound(tdm => tdm.ShortDepartureDate).EditorTemplateName("DatePicker");
columns.Bound(tdm => tdm.TravelDays);
})
.ToolBar(toolBar =>
{
toolBar.Template("<button class='btn btn-default' onclick='addSecondaryDestinationRow()'><i class='fa fa-plus green'></i> Add a Secondary Destination</button><button class='btn btn-default k-grid-cancel-changes'><i class='fa fa-times green'></i> Cancel Changes</button><button class='btn btn-default k-grid-save-changes'><i class='fa fa-cloud-upload green'></i> Save Changes</button>");
})
.Pageable(page => page.Enabled(true).PageSizes(new[] {10, 20, 30, 40}))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Sortable(sorting => sorting.SortMode(GridSortMode.SingleColumn))
.Scrollable()
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
)
On my ShortDeparture date column I've used a EditorsTemplate to add a Bootstrap date picker. Here is the layout of my DatePicker template
@using Bolt.BusinessLogicLayer.Models
@{
var datePickerModel = new DatePickerModel();
}
<div class="input-append date" data-date=@datePickerModel.DefaultDate>
<input id="ShortDepartureDate" name="ShortDepartureDate" class="datepicker" type="text" value=""/>
<span class="add-on"><i></i></span>
</div>
I'm getting a very strange error, when I type into the DatePicker and then post to my controller, the value of my ShortDepartureDate object is set to whatever I typed.
BUT, when I select a value and post to my controller, the value of my ShortDepartureDate is null.
I can see that the value of the date picker is correctly set by making use of the jquery and the date pickers onclick event. Does anyone know why this will be happening?
Update:
The Kendo support team advised me to add the following attribute to my control
data-bind="value: ShortDepartureDate"
This unfortunately didn't work for me and I decided to move away from the inline grid due to time constraints. But perhaps this will help someone else.