I know that something similar was posted and that this may not be supported currently but just want to make sure I've exhausted all options within the Grid API.
I've persisted a scheduled DateTime in UTC. Due to issues with clients in various time zones I'm doing the conversion from UTC on the server (ASP.NET MVC) and casting this value to a string. I would like to re-cast this back to a DateTime instance so that I can make use of the Date filter operators in the appropriate column.
Even if I use Template() the bound property was originally a string and the filter exposes string comparison operators, which I can understand. If I try setting this using Model.Field() the result is the same. Is there a way to override this before the filter renders? Do I need to attach to a DataSource event?
My code:
(Model.ScheduledDelivery is the field in question. We want to allow the user to set a date range for filtering)
@(Html.Kendo().Grid<ScheduledEmailSender.Web.Models.ViewModels.SubmissionViewModel>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(x => x.SubmissionId).Hidden();
columns.Command(command => command.Edit().Text("Edit"));
columns.Command(command => command.Destroy().Text("Delete")).Width(100);
columns.Template(@<text>@GetSummary(item)</text>).ClientTemplate("<div class='email-summary'>#= EmailSubject #</div>").Title("Message Info");
columns.Bound(x => x.ScheduledDelivery).Template(a => a.ScheduledDelivery.AsDateTime())
.Filterable(f => f.Operators(o => o.ForDate(d => d.IsGreaterThanOrEqualTo("Is After").IsEqualTo("Equal To")
.IsLessThanOrEqualTo("Is Before"))));
columns.Bound(x => x.EmailTo).Width(100).Filterable(f => f.Operators(o => o.ForString(s => s.Clear().Contains("Contains"))));
})
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => {
model.Id(p => p.SubmissionId);
})
.Read(read => read.Action("Submissions_AjaxRead", "Home"))
.Destroy(update => update.Action("Submissions_AjaxDelete", "Home"))
.Update(update => update.Action("Submissions_AjaxUpdate", "Home"))
.PageSize(10)
.Events(e => {
e.Sync("refreshGrid");
})
)
.Events(e =>
{
e.DataBound("Grid_dataBound").Remove("Grid_itemRemoved");
})
.Pageable()
.Filterable()
.Editable(edit => edit.Mode(GridEditMode.PopUp).TemplateName("MailEditor"))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
.Sortable()
)
I've persisted a scheduled DateTime in UTC. Due to issues with clients in various time zones I'm doing the conversion from UTC on the server (ASP.NET MVC) and casting this value to a string. I would like to re-cast this back to a DateTime instance so that I can make use of the Date filter operators in the appropriate column.
Even if I use Template() the bound property was originally a string and the filter exposes string comparison operators, which I can understand. If I try setting this using Model.Field() the result is the same. Is there a way to override this before the filter renders? Do I need to attach to a DataSource event?
My code:
(Model.ScheduledDelivery is the field in question. We want to allow the user to set a date range for filtering)
@(Html.Kendo().Grid<ScheduledEmailSender.Web.Models.ViewModels.SubmissionViewModel>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(x => x.SubmissionId).Hidden();
columns.Command(command => command.Edit().Text("Edit"));
columns.Command(command => command.Destroy().Text("Delete")).Width(100);
columns.Template(@<text>@GetSummary(item)</text>).ClientTemplate("<div class='email-summary'>#= EmailSubject #</div>").Title("Message Info");
columns.Bound(x => x.ScheduledDelivery).Template(a => a.ScheduledDelivery.AsDateTime())
.Filterable(f => f.Operators(o => o.ForDate(d => d.IsGreaterThanOrEqualTo("Is After").IsEqualTo("Equal To")
.IsLessThanOrEqualTo("Is Before"))));
columns.Bound(x => x.EmailTo).Width(100).Filterable(f => f.Operators(o => o.ForString(s => s.Clear().Contains("Contains"))));
})
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => {
model.Id(p => p.SubmissionId);
})
.Read(read => read.Action("Submissions_AjaxRead", "Home"))
.Destroy(update => update.Action("Submissions_AjaxDelete", "Home"))
.Update(update => update.Action("Submissions_AjaxUpdate", "Home"))
.PageSize(10)
.Events(e => {
e.Sync("refreshGrid");
})
)
.Events(e =>
{
e.DataBound("Grid_dataBound").Remove("Grid_itemRemoved");
})
.Pageable()
.Filterable()
.Editable(edit => edit.Mode(GridEditMode.PopUp).TemplateName("MailEditor"))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
.Sortable()
)