0

While debugging I can see date fields have date value in retuned JSON but dates are not getting displayed in the grid. Please suggest me a fix.

@(Html.Kendo().Grid<Entities.Details>()
    .Name("grid")
    .HtmlAttributes(new { style = " max-width: 950px ; width: auto " })
    .Columns(columns =>
    {
        columns.Bound(p => p.RuleId).Title("Rule ID").Width(150);
        columns.Bound(p => p.RuleTitle).Title("Rule Title");
        columns.Bound(p => p.ScheduleTitle).Title("Schedule Title");
        columns.Bound(p => p.StartDate).Title("Start Date").Format("{0:h:mm:ss tt}").Width(100);
        columns.Bound(p => p.EndDate).Title("End Date").Format("{0:h:mm:ss tt}").Width(100);
        columns.Bound(p => p.CreatedBy).Title("Created By");
        columns.Bound(p => p.UpdatedBy).Title("Last Updated By");
        columns.Bound(p => p.LastExDate).Title("Last Ex Date").Format("{0:MM/dd/yyyy}").Width(100);
        columns.Bound(p => p.LastExMode).Title("Last Ex Mode");
        columns.Bound(p => p.ExStatus).Title("Last Ex Status");
        columns.Bound(p => p.ExecutedBy).Title("Last Executed By");
        columns.Bound(p => p.ExStatus).Title("Ex Status").Width(110);
    })
    .ToolBar(tools => tools.Excel())
    .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(new int[] { 10, 20, 50, 100 })
            )
    .Sortable()
    .Filterable()
    .Excel(excel => excel
        .FileName("Rule Ex History.xlsx")
        .Filterable(true)
        .AllPages(true)
    )
    .Resizable(r => r.Columns(true))
    .ColumnMenu()
    .DataSource(dataSource => dataSource
        .Ajax().Read(read => read.Action("RuleExHistoryRead", "RuleExHistory"))
CuriousBenjamin
  • 709
  • 1
  • 9
  • 26

1 Answers1

0

Im not sure why they are not being displayed.. that format works for me.

Alternatives: You can do add another field (String) to the model object, like, startDateDescription and fill the value in the server side (RuleExHistoryRead). then in the grid

  columns.Bound(p => p.StartDate).Title("Start Date").Width(100).ClientTemplate("#=startDateDescription");

i didnt put directly the created "description" in the bound because then the filter will do the sorting with a string, in this case it will sort the date and show the text

another way.. if its not a error from the value date:

    columns.Bound(p => p.EndDate).Title("End Date").ClientTemplate("#=EndDate.toString({0:h:mm:ss tt})#").Width(100);
sir_ask
  • 326
  • 1
  • 4
  • 16