We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

hide GMT time for date column in grid

Hi Team,

I have grid and loading data from Data table as below.

 @Html.EJS().Grid("Grid").DataSource((DataTable)ViewBag.FFReport).AllowFiltering().AllowMultiSorting(true).PageSettings(page => page.PageSizes(new List<object>() { 5, 10,15,20,25,30 })).AllowTextWrap(true).AllowPaging(true).AllowExcelExport(true).AllowResizing(true).Height("400").AllowExcelExport().ToolbarClick("toolbarClick").Toolbar(new List<string>() { "ExcelExport" }).FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.Excel); }).AllowGrouping(false).Render()

How to hide the GMT time stamp in date columns.



8 Replies

MF Mohammed Farook J Syncfusion Team November 30, 2018 09:33 AM UTC

Hi Nivas, 
 
Thanks for contacting Syncfusion support. 
 
 
We have validated your requirement and we found from your code, you can generate the column based on the dataSource.  So if we using auto generated column, we need to set the format for the date Column. Please find the code example for your reference. 
 
Code example 
 
 
 
 
@Html.EJS().Grid("Grid").DataBound("dataBound").DataSource((DataTable)ViewBag.FFReport).AllowFiltering().AllowMultiSorting(true).PageSettings(page => page.PageSizes(new List<object>() { 5, 10, 15, 20, 25, 30 })).AllowTextWrap(true).AllowPaging(true).AllowExcelExport(true).AllowResizing(true).Height("400").AllowExcelExport().ToolbarClick("toolbarClick").Toolbar(new List<string>() { "ExcelExport" }).FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.Excel); }).AllowGrouping(false).Render() 
 
<script> 
    function dataBound() { 
        for (var i = 0; i < this.columns.length; i++) { 
            if (this.columns[i].type == 'date' || this.columns[i].type == 'datetime') { 
                this.columns[i].format = { type: 'date', format: 'dd/MM/yyyy' }; 
            } 
 
        } 
        this.refreshColumns(); 
    } 
</script> 
 
 
 
Here we have applied the format for date column by using ‘format’ property in “load” event of Grid. 
 
 
This is not meet your requirement , could you please explain more details about your requirement. 
 
Regards, 
J Mohammed Farook 



NI Nivas November 30, 2018 09:49 AM UTC

Great, its working. thanks. 



NI Nivas November 30, 2018 10:03 AM UTC

hi grid get hang when i load 10 records...Horizontal and vertical bar not moving 


MF Mohammed Farook J Syncfusion Team November 30, 2018 10:23 AM UTC

 Hi Nivas,  
 
Thanks for you update. 
We are happy to hear that the provided solution was helpful to achieve your requirement. 
 
Query : grid get hang when i load 10 records...Horizontal and vertical bar not moving 
Please find the demo for enable scrolling in Grid.  
By default scrolling can be appears and working when the Grid content is exceed than height / width.  Still if you have facing same issue could you please share the following details 
  1. Share the full grid code example with your data.
  2. Share which version of  EJ2 script and DLL version used in your application?
  3. Share the sample if it possible .
  4. Share the console window if have any script error thrown
 
 
Regards, 
J Mohammed Farook 



NI Nivas November 30, 2018 11:30 AM UTC


refreshColumns(); 

Refresh the grid every time when there is movement in grid. so  grid moving to initial potion.


if i remove refresh from the script its working fine but the date format change not reflecting.


MF Mohammed Farook J Syncfusion Team November 30, 2018 11:42 AM UTC

Hi Nivas, 
 
Sorry for inconvenience cause. 
 
We have validated the reported issue and we found the root cause of issue due to called “refreshColumn” method continuously. For avoid this issue we can check the Grid is initial load or not while load event . Please update following code in your application. 
 
 
  
 
 
@Html.EJS().Grid("Grid").Load("load").DataBound("dataBound").DataSource((DataTable)ViewBag.FFReport).AllowFiltering().AllowMultiSorting(true).PageSettings(page => page.PageSizes(new List<object>() { 5, 10, 15, 20, 25, 30 })).AllowTextWrap(true).AllowPaging(true).AllowExcelExport(true).AllowResizing(true).Height("400").AllowExcelExport().ToolbarClick("toolbarClick").Toolbar(new List<string>() { "ExcelExport" }).FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.Excel); }).AllowGrouping(false).Render() 
 
<script> 
    var initialLoad = false; 
    function load() { 
        initialLoad = true; 
    } 
    function dataBound() { 
        if (initialLoad) { 
            initialLoad = false; 
            for (var i = 0; i < this.columns.length; i++) { 
                if (this.columns[i].type == 'date' || this.columns[i].type == 'datetime') { 
                    this.columns[i].format = { type: 'date', format: 'dd/MM/yyyy' }; 
                } 
 
            } 
            this.refreshColumns(); 
        } 
    } 
</script> 
 
 
Regards, 
J Mohammed Farook 



NI Nivas November 30, 2018 11:52 AM UTC

working fine, Thanks for the help....



MF Mohammed Farook J Syncfusion Team November 30, 2018 12:31 PM UTC

Hi Nivas,  
Thanks for the update.   
 
We are happy to hear that your problem has been resolved. 
 
Regards, 
J Mohammed Farook 


Loader.
Live Chat Icon For mobile
Up arrow icon