Nov 20, 2014, 3:42 AM
CompositeField on PropertyGrid
Hello,
I have a CompositeField (DateField and TimeField) inside a PropertyGrid. The problem is that when the date or time is changed, the PropertyChange event is not fired. Here is my code:
PropertyGrid:
Thank you in advance.
Regards
Alex
I have a CompositeField (DateField and TimeField) inside a PropertyGrid. The problem is that when the date or time is changed, the PropertyChange event is not fired. Here is my code:
PropertyGrid:
<ext:PropertyGrid ID="GeneralConfig" runat="server" Height="399" HideHeaders="true"
Title="">
<Source>
<ext:PropertyGridParameter Name="inicio_sufragio" DisplayName="Fecha y hora" Value="">
<Renderer Fn="fechaIni_Render" />
<Editor>
<ext:CompositeField runat="server" ID="CompositeField1">
<Items>
<ext:DateField ID="DateField1" runat="server" Format="dd/MM/yyyy" Width="120" />
<ext:TimeField ID="TimeField1" runat="server" Format="HH:mm" Width="80" />
</Items>
</ext:CompositeField>
</Editor>
</ext:PropertyGridParameter>
</Source>
<DirectEvents>
<PropertyChange OnEvent="EventoModificar">
<ExtraParams>
<ext:Parameter Name="nombre" Value="recordId" Mode="Raw" />
<ext:Parameter Name="nuevo" Value="value" Mode="Raw" />
<ext:Parameter Name="anterior" Value="oldValue" Mode="Raw" />
</ExtraParams>
</PropertyChange>
</DirectEvents>
<View>
<ext:GridView ID="GridView2" ForceFit="true" ScrollOffset="2" runat="server">
<GetRowClass Handler="return record.data.name.substring(0, 6) == 'separa' ? 'pg-sep' : '';" />
<Listeners>
<Refresh Handler="this.grid.colModel.setColumnWidth(0, 570); this.grid.colModel.setColumnWidth(1, 350);" />
</Listeners>
</ext:GridView>
</View>
<Listeners>
<Render Handler="this.getStore().sortInfo = undefined;" />
<BeforeRender Handler="var columns = this.getColumnModel().config;
columns[0].sortable = false; columns[1].sortable = false;" />
</Listeners>
</ext:PropertyGrid>
Javascript render function: <script type="text/javascript">
var fechaIni_Render = function (value) {
return #{DateField1}.getValue().toLocaleDateString() + ' ' + #{TimeField1}.getValue();
}
</script>
Code-behind to assign value to propertygrid on page load and to get modified value: protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DateTime fecha = DateTime.Now;
this.GeneralConfig.Source["inicio_sufragio"].Value = fecha.ToString("dd/MM/yyyy HH:mm");
DateField1.SetValue(fecha.ToString("dd/MM/yyyy"));
TimeField1.SetValue(fecha.ToString("HH:mm"));
}
}
public void EventoModificar(object sender, DirectEventArgs e)
{
var valorNuevo = e.ExtraParams["nuevo"];
var valorAnterior = e.ExtraParams["anterior"];
var nombre = e.ExtraParams["nombre"];
....
}
Any hint will be greatly appreciated.Thank you in advance.
Regards
Alex