Articles in this section
Category / Section

How to format date values received in JSON data through ajax post

1 min read

Problem

      The date column value is obtained in the format “\ /Date(628318530718)\/.

Cause

       The date column value is not formatted when it is retrieved from the server via AJAX post.

Solution

         The unformatted JSON date value can be formatted by ej.data.DataUtil.parse.parseJSON function in the AJAX success event.

function getDataSource() { 
            var grid = document.getElementsByClassName("e-grid")[0].ej2_instances[0];
// Grid instance 
            var ajax = new ej.base.Ajax('/Home/UrlDatasource', 'POST'); 
            ajax.send(); 
            ajax.onSuccess = function (data) { 
                grid.dataSource = ej.data.DataUtil.parse.parseJson(data);   //parse using DataUtil.parse.parseJson method 
            }; 
    } 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied