json does not become in datetime

Good morning,

I have the following problem, attached in an image



As you can see when the data arrives at the controller of the grid, some dates do not convert them, so when filtering in ascending or descending it does not do it correctly, what do I do wrong? this is my code



Thanks



6 Replies

MP Manivannan Padmanaban Syncfusion Team July 16, 2018 12:54 PM UTC

Hi Cesar, 

Thanks for contacting syncfusion support. We are happy to assist you. 

From the attached screenshot, we could see that in the filter dialog the datetime values are displayed as string value instead of date-time value. The mentioned issue will occur in the below two cases, 

Case 1 

If the datetime column values are not date object, then the values are displayed as string value only. So, please ensure whether are you bind date object value to the date time column.  
 
Case 2 
 
If the datasource value, is in string object at that time also the reported issue will occur. So, we need to parse the string object to JSON object using ej.parseJSON helper function. Refer the below link, 
 
 
<script type="text/javascript"> 
        $(function () { 
            $("#Grid").ejGrid({ 
                dataSource: ej.parseJSON(Data), 
              allowFiltering:true, 
              filterSettings:{filterType:"Excel"}, 
                allowPaging: true, 
 
                columns: [ 
                        { field: "OrderDate", format: "{0:MM/dd/yyyy hh:mm:ss}",headerText: 'Due Date', width: 80 },                 
                ] 
            }); 
 
        }); 
    </script> 
 
 

For your convenience we have created the sample please refer the below link, 

After referring the above details still, facing the issue please get back to us with the following details. 

  1. Reproduce the issue in the provided sample and revert as back.
  2. Share the data Source (i.e. grid data)
  3. And also, in the attached screenshot we could see that before 18/06/2018 11:24:25 record few other additional records are added in the excel filter dialog. So, could you please confirm whether are you using any additional events to add the record in excel filter dialog. If yes, please share the details.
  4. Share the complete grid code example.

Regards, 
Manivannan Padmanaban. 

 



CE cesar July 19, 2018 09:53 PM UTC

thanks for your reply

Now I have the same problem with the pivotClient, even though I do the ej.parseJson I can not make the date my object date, what do I do wrong?






what is wrong?


SA Scintilla Arul Jothi Raj Syncfusion Team July 20, 2018 03:36 PM UTC

Hi Cesar, 

Sorry for the inconvenience caused. 

We have confirmed that-“Need to convert the date object to date format” is an issue and we have logged a  defect report. The fix for this issue will be included in the Essential Studio Volume 2 SP2 release which is estimated to be available by the end of August 2018. 

Please let us know, if you have any concerns. 

Regards, 
Scintilla A 



TM Tamilarasu M Syncfusion Team August 29, 2018 10:45 AM UTC

Hi Cesar, 
 
We are glad to announce that our Essential Studio Volume 2 SP2 2018 (v16.2.0.50) is rolled out and is available for download under the following link. 
 
The fix for the issue “Need to convert the date object to date format” is included in this version. Please find the sample and screenshot in the below link 
 
 
 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards, 
Tamilarasu  



FO fostercarly August 2, 2021 04:56 AM UTC

JSON does not know anything about dates. What .NET does is a non-standard hack/extension. The problem with dates in JSON and really JavaScript in general – is that there's no equivalent literal representation for dates. In JavaScript following Date constructor straight away converts the milliseconds since 1970 to Date as follows:

var jsonDate = new Date(1297246301973);

Then let's convert it to js format:

var date = new Date(parseInt(jsonDate.substr(6)));

The substr() function takes out the /Date( part, and the parseInt() function gets the integer and ignores the )/ at the end. The resulting number is passed into the Date constructor .





MM Manikandan Murugesan Syncfusion Team August 2, 2021 11:53 AM UTC

Hi Fostercarly, 
 
Kindly use the “ej.parseJSON” method to convert JSON date into JavaScript/jQuery date. We have made the same changes that you have mentioned. Please refer the following sample and screenshot. 
 
 
Screenshot: 
 
 
 
 
Please let us know if you have any concerns. 
 
Regards, 
Manikandan 


Loader.
Up arrow icon