PDA

View Full Version : [CLOSED] Date format in PropertyGrid



developeriw
Oct 21, 2014, 2:00 PM
Hi,

I have a PropertyGrid (Ext.Net MVC 2.5.2) and some parameters (line in the grid) are of type date. The editor has the format I specified ("dd/MM/yyyy") but after I finish to edit (so after the editor is done) the format of the date become "MM/dd/yyyy". I have tried the solution from http://www.sencha.com/forum/showthread.php?20225-Date-format-on-PropertyGrid, I have put this in my page:


<script>
if (Ext.grid.PropertyColumnModel) {
Ext.apply(Ext.grid.PropertyColumnModel.prototype, {
nameText: "Nume",
valueText: "Valoare",
dateFormat: "dd/MM/yyyy"
});
}
</script>

The name of the columns "Name" and "Value" are changed with the names I supplied, but the date format remains wrong ("MM/dd/yyyy").

The PropertyGrid is very simple:


Html.X().PropertyGrid()
.Title("<b>Atribute</b>")
.NameColumnWidth(400)
.ID("AttributesPropertyGrid" + entityId)
.Height(150)

The source is set on the server-side:


var paramCollection = new PropertyGridParameterCollection();
var param = new PropertyGridParameter();
param.Name = attr.Name;
param.Editor.Add(new DateField() { Format = "dd/MM/yyyy" });
paramCollection.Add(param);

var attributesPropertyGrid = this.GetCmp<PropertyGrid>("AttributesPropertyGrid" + entityId.ToString());
attributesPropertyGrid.SetSource(paramCollection, true);

Thanks!

Daniil
Oct 21, 2014, 4:20 PM
Hi @developeriw,

Welcome to the Ext.NET forums!

Please use:

Ext.grid.PropertyColumnModel.override({
nameText: "Nume",
valueText: "Valoare",
renderDate: Ext.util.Format.dateRenderer("j/m/Y")
});

developeriw
Oct 22, 2014, 7:43 AM
Thanks Daniil, it works!