PDA

View Full Version : [CLOSED] Rowediting - disable Key Record Field when updating the row



tanky65
Feb 27, 2013, 5:10 AM
consider the following example [http://examples2.ext.net/#/GridPanel/Plugins/RowEditor_Remote/]

5724

consider I'm not so practice with client side code prog.:

1. How could I set the key record field as disabled when I enter the row editing in update mode (double click on the row) and leave it enabled only in insert mode (after button Add is pressed) ?

2. if i need to add action code after button Update in row edited is pressed, is it correct to do it in ValidateSave func. or are there other events that should be better to use?

thanks

Vladimir
Feb 27, 2013, 10:54 AM
Hi,

1. Set ItemID for editor field (for example, Name) and use the following listener in RowEditing plugin


<BeforeEdit Handler="this.editor.getComponent('Name').setDisabled(!e.re cord.phantom);" />


2. Event may depend from action code which you should execute. Final event is Edit, ValidateEdit is called before edit (if ValidateEdit returns false then editing will be canceled)

tanky65
Feb 27, 2013, 9:01 PM
Thanks,

furthermore, which is the difference between using SaveHandler on RowEditing or defining a listener ValidateEdit and Edit ?

thanks again



<ext:RowEditing ID="RowEditing1" runat="server" SaveHandler="validateSave">
<Listeners>
<BeforeEdit Handler="this.editor.getComponent('ediClusterId').setDisabl ed(!e.record.phantom);" />
<ValidateEdit Handler="......." />
<Edit Handler="......." />
</Listeners>
</ext:RowEditing>

Vladimir
Feb 28, 2013, 4:15 AM
Using SaveHandler you can able to perform remote validations
ValidateEdit allows client side validations only because required return validation status from event handler
Edit event is fired after success editing of record

Here is docs for those events
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.plugin.Editing-event-validateedit
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.plugin.Editing-event-edit

tanky65
Feb 28, 2013, 9:08 AM
Hi,

1. Set ItemID for editor field (for example, Name) and use the following listener in RowEditing plugin


<BeforeEdit Handler="this.editor.getComponent('Name').setDisabled(!e.re cord.phantom);" />


2. Event may depend from action code which you should execute. Final event is Edit, ValidateEdit is called before edit (if ValidateEdit returns false then editing will be canceled)

Vladimir, this works but I need to get in the values passed to the validation function also the key field I have disabled.
In the JsonObject values I can find only the enabled field subject of the update.


public object ValidateSave(bool isPhantom, JsonObject values)

is it possible?
Thnaks

Vladimir
Feb 28, 2013, 9:38 AM
If you need to submit disabled fields then you can enable it before calling getValues and disable after again


this.getComponent('Name').setDisabled(false);
App.direct.ValidateSave(plugin.context.record.phan tom, this.getValues(false, false, false, true), {
success : function (result) {
if (!result.valid) {
Ext.Msg.alert("Error", result.msg);
return;
}


plugin.completeEdit();
}
});
this.getComponent('Name').setDisabled(!plugin.cont ext.record.phantom);

tanky65
Mar 01, 2013, 6:08 PM
ok, thanks, it worked