PDA

View Full Version : EditorGrid isDirty()



DHainzl
23 Jul 2010, 1:58 AM
Hello there,
I am using a editorgrid to display data. But I don't want to send the new data instantly the user edits the grid, instead I have a save-button to save the whole grid at once. Now I'm testing if my form isDirty() to decide if the save-dialog should be shown or not. This is my layout:
Form <<-- The form I want to use isDirty() on
Panel


CompositeField



EditorGrid <<-- The grid with the values



HelpButton <<-- Only a DisplayField with a qtip
Now I tried to extend the EditorGridPanel with a isDirty()-function:


Ext.ux.DirtyEditorGridPanel = Ext.extend (Ext.grid.EditorGridPanel, {
isDirty : function(){
var dirty = false;
this.items.each(function(f){
if(f.isDirty()){
dirty = true;
return false;
}
});
return dirty;
}
});
Ext.reg ('dirtyeditorgridpanel', Ext.ux.DirtyEditorGridPanel);I do not know if it works, as the function is never called. I am adding the dirtyeditorgridpanel to the compfield, but when I step through the isDirty()-call Stack, the composite has only one item, which is my help-button. Here's how I include the editorgrid:


Ext.ux.mk.site.table.Privatkosten = Ext.extend (Ext.Panel, {
initComponent: function ()
{
var gridData = Array();

for (var i = 0; i < this.children.length; i++)
{
var beforeLength = gridData.length;

for (var j = 0; j < this.children[i].children.length; j++)
{
// TODO absprechen mit Clemens wie children aussehen
var werte;
if (this.children[i].children[j].wert == null)
{
werte = new Array ("", "monatlich");
}
else
{
werte = this.children[i].children[j].wert.split ('>>||<<');
}

gridData[beforeLength + j] =
{
'id_feld' : this.children[i].children[j].id_feld,
'id_tree' : (beforeLength + j), // Zum sortieren
group: this.children[i].label,
label: this.children[i].children[j].label,
betrag: werte[0],
zahlweise: werte[1]
}
}
}

Ext.apply (this, {
title: this.label,
items:
[
{
xtype: 'helpitem',
// fieldLabel: this.label,
helpText: this.quickinfo,
items:
[
{
xtype: 'dirtyeditorgridpanel',
value: this.wert,
height: 450,
clicksToEdit: 1,
flex: 1,
// anchor: '50%',
name: this.id_wert + '_feld_' +this.id_feld,
enableColumnHide: false,
enableColumnMove: false,
enableHdMenu: false,
trackMouseOver: true,
ds: new Ext.data.GroupingStore ({
reader: new Ext.data.JsonReader ({
idProperty: 'id_feld',
fields:
[
{ name: 'id_feld', type: 'int' },
{ name: 'id_tree', type: 'int' },
{ name: 'group', type: 'string' },
{ name: 'label', type: 'string' },
{ name: 'betrag', type: 'string' },
{ name: 'zahlweise', type: 'string' }
]
}),
data: gridData,
sortInfo: {field: 'id_tree', direction: 'DESC'},
groupField: 'group'
}),

columns:
[
{
header: 'Art',
dataIndex: 'label',
editor: new Ext.form.TextField ({
}),
summaryRenderer: function (v, params, data)
{
return 'Summe (monatlich)';
}
},
{
header: 'Gruppe',
dataIndex: 'group'
},
{
header: 'Betrag',
dataIndex: 'betrag',
summaryType: 'costspermonth',
editor: new Ext.form.NumberField ({
allowBlank: false,
allowNegative: false
}),
renderer: function (v)
{
return v + ' ';
}
},
{
header: 'Zahlweise',
dataIndex: 'zahlweise',
editor: new Ext.form.ComboBox ({
store: zahlweiseDataStore,
mode: 'local',
displayField: 'zahlweise',
triggerAction: 'all',
editable: false
})

}
],

view: new Ext.grid.GroupingView({
forceFit: true,
showGroupName: false,
enableNoGroups: false,
enableGroupingMenu: false,
hideGroupedColumn: true
}),
plugins: new Ext.ux.grid.GroupSummary()
}
]
}
]
});
Ext.ux.mk.site.table.Privatkosten.superclass.initComponent.call (this, arguments);
}
});
Ext.reg ('sitextablexprivatkosten', Ext.ux.mk.site.table.Privatkosten);

So the editorGrid is never called ... Can you tell me how to make that work? I'll provide additional information if you need it ...

-- Hoazl