Browse Source

properly implement loading/submitting forms via the "pk" option.

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
2465b23aef
  1. 24
      pyweb/extdirect.py

24
pyweb/extdirect.py

@ -53,16 +53,26 @@ Ext.ux.%(clsname)s = function( config ){
this.form.api = %(apiconf)s; this.form.api = %(apiconf)s;
this.form.paramsAsHash = true; this.form.paramsAsHash = true;
if( typeof config.pk != "undefined" ){
this.load();
}
} }
Ext.extend( Ext.ux.%(clsname)s, Ext.form.FormPanel, {} );
Ext.extend( Ext.ux.%(clsname)s, Ext.form.FormPanel, {
load: function(){
this.getForm().load({ params: {pk: this.pk} });
},
submit: function(){
this.getForm().submit({ params: {pk: this.pk} });
},
} );
Ext.reg( '%(clslowername)s', Ext.ux.%(clsname)s ); Ext.reg( '%(clslowername)s', Ext.ux.%(clsname)s );
""" """
# About the this.form.* lines, see # About the this.form.* lines, see
# http://www.sencha.com/forum/showthread.php?96001-solved-Ext.Direct-load-data-in-extended-Form-fails-%28scope-issue%29 # http://www.sencha.com/forum/showthread.php?96001-solved-Ext.Direct-load-data-in-extended-Form-fails-%28scope-issue%29
class Provider( object ): class Provider( object ):
""" Provider for Ext.Direct. This class handles building API information and """ Provider for Ext.Direct. This class handles building API information and
routing requests to the appropriate functions, and serializing their routing requests to the appropriate functions, and serializing their
@ -445,14 +455,8 @@ class Provider( object ):
'paramsAsHash: true,' 'paramsAsHash: true,'
"""buttons: [{ """buttons: [{
text: "Submit", text: "Submit",
handler: function(){
form = this.ownerCt.ownerCt;
form.getForm().submit({
params: {
uid: 34
}
});
}
handler: this.submit,
scope: this
}]""" }]"""
'}', '}',
'apiconf': ('{' 'apiconf': ('{'

Loading…
Cancel
Save