Nov 04, 2013, 1:25 PM
[CLOSED] CellEditing Listeners and Column Renders
I have column renderers that are changing the style based on the IsActive field. The IsActive field is calculated based on the DateActivated and DateInactivated fields.
I believe my issue is that when the DateActivated or DateInactivated fields are edited I recalculate the IsActive field, but the renderers have already fired before I can change the IsActive field. If that is true that the renderers for a column fire before the Edit listener on the cell I have an problem. I need the renderers to fire after I change the IsActive field manually.
1) I would guess the most efficent approach would be to refire the column renderers if the IsActive field is changed during the Edit listener. Is this possible?
I believe my issue is that when the DateActivated or DateInactivated fields are edited I recalculate the IsActive field, but the renderers have already fired before I can change the IsActive field. If that is true that the renderers for a column fire before the Edit listener on the cell I have an problem. I need the renderers to fire after I change the IsActive field manually.
1) I would guess the most efficent approach would be to refire the column renderers if the IsActive field is changed during the Edit listener. Is this possible?
...
<script type="text/javascript">
var template = 'color:{0};';
function styleColor(value, meta) {
var testField = meta.record.data["IsActive"];
meta.style = Ext.String.format(template, testField ? "green" " black");
return value;
}
function dateWithStyleColor(value, meta) {
return Ext.Date.format(styleColor(value, meta), 'Y-m-d');
}
function cellEdit (editor, e) {
if (e.field == "DateActivated" || e.field == "DateInactivated") {
e.record.data.IsActive = (e.record.data.DateActivated !== null && e.record.data.DateActivated <= new Date()) &&
(e.record.data.DateInactivated == null || e.record.data.DateInactivated > new Date());
}
}
</script>
...
<ext:Column runat="server" Text="Name" DataIndex="BaseNm">
<Renderer Fn="styleColor" />
<Editor>
<ext:TextField runat="server" MaxLength="25" EnforceMaxLength="true" AllowBlank="false" />
</Editor>
</ext:Column>
<ext:Column runat="server" Text="Activated" DataIndex="DateActivated">
<Renderer Fn="dateWithStyleColor" />
<Editor>
<ext:DateField runat="server" Format="Y-MM-dd" />
</Editor>
</ext:Column>
<ext:Column runat="server" Text="Inactivated" DataIndex="DateInactivated">
<Renderer Fn="dateWithStyleColor" />
<Editor>
<ext:DateField runat="server" Format="Y-MM-dd" />
</Editor>
</ext:Column>
<ext:Column runat="server" Text="IsActive" DataIndex="IsActive" Hidden="true" Hideable="false" />
...
<Plugins>
<ext:CellEditing runat="server">
<Listeners>
<Edit Fn="cellEdit" />
</Listeners>
</ext:CellEditing>
</Plugins>
Last edited by Daniil; Nov 05, 2013 at 2:38 PM.
Reason: [CLOSED]