$("#Grid").ejGrid({
dataSource: data,
actionBegin: "onActionBegin",
columns: [
{ field: "OrderDate", headerText: "Order Date", width: 80, type: "date", textAlign: ej.TextAlign.Right, priority: 2 },
. . .
]
});
function onActionBegin(args){
if(this.initialRender)
{
var cols = this.model.columns;
for(var i=0;i<cols.length;i++){
if(cols[i].type == "date") // detect the date type column
cols[i].format="{0:MM/dd/yyyy}"; // set the format for that column
}
}
} |
<div id="Grid"
data-ej-columns="[{'field': 'OrderID', 'allowFiltering':false},{'field': 'ShipCity'},{'field': 'OrderDate','type':'date'},]"
data-role="ejgrid"
data-ej-actionbegin="onActionBegin"
data-ej-allowpaging="true"
data-ej-isresponsive="true"
data-ej-allowfiltering="true"
data-ej-filtersettings-filtertype="menu"></div>
</div> |