How to set default sort column in extjs4 grid and change date format?

1- How to set a column for sorting when creating a grid? , after reloading the grid, it automatically uses this view to display records properly. ) Is it possible to do this on the grid itself so that it does not depend on the main data warehouse?

2- How to change the display of the date format in the grid column? my data displays a date like /Date(1316020760837+0000)/ I tried using renderer: Ext.util.Format.dateRenderer('m/d/Y'),// format: 'md Y' but it gives me NaN/NaN/NaN

Any help would be appreciated. thanks

+6
source share
1 answer

resolved:

  • I used sortOnLoad with sorters

     var myStore = new Ext.data.JsonStore({ fields: ['Item1', 'Item2', 'Item3', 'Item4'] , data: [] , sortOnLoad: true , sorters: { property: 'Item1', direction : 'DESC' } }); 
  • in my C # code, I used item.DateEnd.ToString("MMM dd, yyyy") . see this or this for standard and custom format

or better in extjs4, you must specify dateFormat so that Ext can parse it correctly, and you will make sure it is read normally.

  {name: 'Item1' , type : 'date',dateFormat :'MS'} 

u can see this for available format strings.

+18
source

Source: https://habr.com/ru/post/897479/


All Articles