Hybrid View
-
27 Feb 2011 1:50 AM #1
Form <-> Model binding
Form <-> Model binding
In the comments of the blog about the new data package Ed Spencer mentioned that it is or will be possible to bind form data to a model (s. below).
I can´t find more details in the API docs. Is this feature already available?
2) Indeed - I prefer to do everything through the Model and just use the form for dumb data collection
3) Yes - if you configure a form with a Model it will ask the Model to validate itself, showing any errors on the appropriate field. This makes it easy to create very powerful validations
-
27 Feb 2011 7:40 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
Have you tried using the loadRecord method on the form? Sencha Touch and ExtJS 3 has this.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
27 Feb 2011 9:07 AM #3
A model is more complex than a record. As far as I know a record is just a flat collection of fields. A model can furthermore contain associations. So a model can be a huge object tree.
BTW the Ext.data.Record class seem to have gone in Ext 4.
I know the model binding from Flex (BlazeDS). There you can exchange objects between frontend and backend and vice versa. Additionally there are tools that generate the frontend models from the backend models. So they are in sync at every time of development state. This makes life really easy.
Would be great to have something like that in ExtJS.
-
27 Feb 2011 9:14 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
According to the API docs for ExtJS 4... do this:
Model and Record mean the same in ExtJS4/ST.Code:formpanel.getForm().loadRecord(rec);
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
27 Feb 2011 10:07 AM #5
I´ve just had a look at the ExtJS 4 source code and I can´t imaging that this will work. The loadRecord method calls setValues and this method just tries to set the values of the form fields. So far it may work for fields and array. But I don´t see a way to have 1:1 relationships between two objects yet. On the other side I don't think that the reverse method udpateRecord does it's work in deep hierarchy.
Despite of my doubts I will give it a try.
-
28 Feb 2011 6:16 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
How is it making out for you?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
Similar Threads
-
[FIXED] Selection Model Binding Problem When Using Multiple Grids
By j-joey in forum Ext Designer: BugsReplies: 5Last Post: 15 May 2012, 8:06 PM -
Form Binding to BeanModel
By zathril in forum Ext GWT: DiscussionReplies: 0Last Post: 28 Mar 2010, 1:08 PM -
Form binding / update model
By tsegismont in forum Ext GWT: Help & Discussion (1.x)Replies: 0Last Post: 2 Apr 2009, 1:22 AM -
Form binding
By exo in forum Ext 1.x: Help & DiscussionReplies: 1Last Post: 16 Apr 2007, 4:20 AM


Reply With Quote