-
25 Jan 2013 1:43 PM #1
Answered: FieldSet - loadRecord?!
Answered: FieldSet - loadRecord?!
Hey there,
i have a problem to reference my fieldset/form in my controller and load the record in it.
View:
Controller:Code:Ext.define('RAR.view.order.OrderForm' ,{ extend: 'Ext.form.FieldSet', alias : 'widget.orderform', margin: '0 0 0 10', title:'Order details', defaults: { width: 240, labelWidth: 90 }, defaultType: 'textfield', items: [{ fieldLabel: 'Id', name: 'IDrec' },{ fieldLabel: 'Firma', name: 'Firma' },{ fieldLabel: 'Nettosumme', name: 'NSumme' },{ xtype: 'datefield', fieldLabel: 'Datum', name: 'RecDatum' }] });
When I excecute this i get the error: "TypeError: this.getOrderForm(...).getForm is not a function"Code:Ext.define('RAR.controller.OrderController', { extend: 'Ext.app.Controller', stores: ['Orders'], models: ['Order'], views: [ 'order.OrderGrid', 'order.OrderForm', 'order.OrderPanel' ], refs: [{ ref: 'orderForm', selector: 'orderform' }], init: function() { this.control({ 'ordergrid': { selectionchange: this.gridSelectionChange } }); }, gridSelectionChange: function(model, records) { if (records[0]) { this.getOrderForm().getForm().loadRecord(records[0]); } } });
Before this, I tried it with another reference into the OrderController:
This works, but now I must specify the form I would fill.Code:refs: [{ ref: 'orderForm', selector: 'form' }],
I think my question is now: Which function or reference I can use to load the record in my FieldSet.
Thanks for your time.
Jakob
-
Best Answer Posted by skirtle
You can't. The selector is 'form', which will match an Ext.form.Panel, not the fieldset.
To target more specific components you can use a custom xtype (via subclassing) or an itemId. Personally I wouldn't use an itemId unless I also have a custom xtype earlier in the selector.
If you haven't already, make sure you've read this explanation of component queries:
http://docs.sencha.com/ext-js/4-1/#!...ComponentQuery
Perhaps I still haven't understood your question?
-
25 Jan 2013 4:18 PM #2
A fieldset is not a form. The method's getForm and loadRecord are method's of Ext.form.Panel:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.Panel
Whereas what you have is a Ext.form.FieldSet:
http://docs.sencha.com/ext-js/4-1/#!....form.FieldSet
If you only have a small number of fields then you could just copy the values from the record manually. If you really want to use loadRecord then just add in a form. i.e. Make the first child of the fieldset a form and move the fields inside it.
-
26 Jan 2013 10:37 AM #3
Thanks for reply!
I get the point, but why can i reference the same fieldset with
and then I can use the loadRecord method. Is there a possibility to specify this reference to get alwas the right form? Do u know what I mean?Code:refs: [{ ref: 'orderForm', selector: 'form' }],
Greets, Jakob
-
26 Jan 2013 4:00 PM #4
You can't. The selector is 'form', which will match an Ext.form.Panel, not the fieldset.
To target more specific components you can use a custom xtype (via subclassing) or an itemId. Personally I wouldn't use an itemId unless I also have a custom xtype earlier in the selector.
If you haven't already, make sure you've read this explanation of component queries:
http://docs.sencha.com/ext-js/4-1/#!...ComponentQuery
Perhaps I still haven't understood your question?
-
26 Jan 2013 4:48 PM #5


Reply With Quote