Hi Bianca,
We checked the problem reported in the attached video demo and would like to let you know that the problem is occurring due to the date time column values getting converted to local time-zone in the documentation from your side and hence the date filter not properly performed since the displayed and underlying data value are different. We have explained this case in detail below for your reference,
The Grid component will automatically convert UTC to local time and display it in the Grid which is the default behavior. So in the mentioned documentation link the first ‘OrderDate’ column value that is present in the Grid’s dataSource is “4th July 1996” and you can check it in the below screenshot image for reference,
Now when it is displayed in the Grid it will automatically be converted to local time based on the time-zone and displayed which is why the first date column value is displayed as “3rd July 1996” in your system(due to the time-zone reduction in the value). So when you try to filter “7/3/1996” no result will be displayed but the result will be returned when inputting the filter value as – “7/4/1996”. This is the default behavior of this case and the filter needs to be performed based on the underlying data value.
However you can prevent the time-zone reduction and display the UTC time itself in the Grid by setting the DataUtil’s serverTimezoneOffset property of the EJ2 Data as ‘0’.
This is demonstrated in the below code snippet,
<script>
ej.data.DataUtil.serverTimezoneOffset = 0;
</script> |
So using this property you can set the time offset value as your local time-zone offset value to display the datetime values without converting it to local time-zone.
Note: This approach will only work when remote data is bound to the Grid. For displaying the date value in UTC format itself when local data in bound to the Grid, the stringified data needs to first parsed using DataUtil’s parseJson method of the EJ2 Data before assigning as the Grid data source. This is demonstrated in the below code snippet,
var data = @Html.Raw(Json.Serialize(ViewBag.datasource));
// Grid’s created event handler
function onCreated() {
var gridObj = document.getElementById('Grid').ej2_instances[0];
ej.data.DataUtil.serverTimezoneOffset = 0;
gridObj.dataSource = new ej.data.DataUtil.parse.parseJson(JSON.stringify(data));
} |
Let us know if you have any concerns.
Regards,
Sujith R