DateTime displayed incorrectly when loaded in spreadsheet

2 posts, 0 answers
  1. Nithiya
    Nithiya avatar
    2 posts
    Member since:
    May 2017

    Posted 09 Nov 2017 Link to this post


    I am loading a spreadsheet with the help of a dataset result. I have a stored procedure that output's the result to a dataset and this dataset is being loaded to a datatable and rendered on the speadsheet using datasource. Below is my code

    public ActionResult Products_Load([DataSourceRequest]DataSourceRequest request)
                DataTable dt = new DataTable();
                DataSet dsGetData = HandlerUtilities.HandlerFunctions.GetDynamicSheetData(1, 4);
                if (dsGetData != null)
                    dt = dsGetData.Tables[0];
                DataSourceResult result = dt.ToDataSourceResult(request);
                JsonResult oJsonResult = Json(result, JsonRequestBehavior.AllowGet);
                return oJsonResult;


    When the data is rendered on the spreadsheet, the datetime values are getting converted into /Date(xxxxxx)/ instead of original values. I have attached the screenshot of my output for reference. My dataset is dynamic and everytime it will get changed and due to this I am not using a view model to bind the data.  Hence, I cant provide the fieldname and its format in the client side as I dont know what the fieldnames will be. Is there any workaround fr this?

  2. Veselin Tsvetanov
    Veselin Tsvetanov avatar
    824 posts

    Posted 13 Nov 2017 Link to this post

    Hi Nithiya,

    In order to properly display Date values in a Spreadsheet with DataSource configured, you will need to pass the appropriate type to the DataSource.schema.model.fields configuration. In case you columns are dynamically loaded and they are not known in advance, you will need to dynamically configure that option. In this case you could predefine an empty Spreadsheet:
        .HtmlAttributes(new { style = "width:100%; height: 700px" })
        .Sheets(sheets =>

    And configure its DataSource on initial page load:
    $(document).ready(function () {
        var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
        var sheet = spreadsheet.activeSheet();
            url: '@(Url.Action("GetFieldsForSpreadsheet", "Data"))',
            success: function (result) {
                var cols = [];
                var fields = {};
                for (var i = 0; i < result.Data.length; i++) {
                    var currentField = result.Data[i];
                        field: currentField.ColumnName,
                        title: currentField.Title,
                        type: currentField.ColType
                    fields[currentField.ColumnName] = {
                        type: currentField.ColType
                var dataSource = new{
                    batch: true,
                    transport: {
                        read: '@(Url.Action("Spreadsheet_Read", "Data"))'
                    schema: {
                        model: {
                            id: "Id",
                            fields: fields
                sheet.setDataSource(dataSource, cols);

    Where the GetFieldsForSpreadsheet call should return the definition of the currently loaded columns. For example:
    public ActionResult GetFieldsForSpreadsheet()
        var result = new List<ColumnSettings>()
            new ColumnSettings() { ColumnName = "Id", Title = "Title Id", ColType = "number" },
            new ColumnSettings() { ColumnName = "Group", Title = "Title GROUP", ColType = "string" },
            new ColumnSettings() { ColumnName = "Date", Title = "Date", ColType = "date" }
        return Json(new { Data = result }, JsonRequestBehavior.AllowGet);

    Attached you will find a simple MVC project, implemnting the above suggestion.

    Veselin Tsvetanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top