1. Create a model

Source: Internet
Author: User

Data Model of extjsBlog type:

  • Extjs
 

1. Create a model

 

Java code
  1. // We use Ext. Define to create our model class.
  2. // DB table person (name, age, email)
  3. Ext. Define ("person ",{
  4. Extend: "Ext. Data. model ",
  5. Fields :[
  6. {Name: 'name', type: 'auto '},
  7. {Name: 'age', type: 'int '},
  8. {Name: 'email ', type: 'auto '}
  9. ]
  10. });
  11. // We use Ext. regmodel to create our model class.
  12. // In MVC mode, the model must be m-layer.
  13. Ext. regmodel ("user ",{
  14. Fields :[
  15. {Name: 'name', type: 'auto '},
  16. {Name: 'age', type: 'int '},
  17. {Name: 'email ', type: 'auto '}
  18. ]
  19. });
// We use Ext. define to create our model class // dB table person (name, age, email) Ext. define ("person", {extend: "Ext. data. model ", fields: [{Name: 'name', type: 'auto'}, {Name: 'age', type: 'int'}, {Name: 'email ', type: 'auto'}]}); // use Ext. regmodel to create our model class // in MVC mode, the model must be m-layer Ext. regmodel ("user", {fields: [{Name: 'name', type: 'auto'}, {Name: 'age', type: 'int '}, {Name: 'email ', type: 'auto'}]});

2. Create a model instance and how to instantiate an object

Java code
  1. // Instantiate our person (here are three methods)
  2. // 1 New Keyword
  3. VaR P = new person ({
  4.  
  5. Name: 'baomengjie ',
  6. Age: 23,
  7. Email: '[email protected]'
  8. });
  9. // Alert (P. Get ());
  10.  
  11. // 2 Ext. Create (officially recommended)
  12. VaR p1 = ext. Create ("person ",{
  13.  
  14. Name: 'baomengjie ',
  15. Age: 23,
  16. Email: '[email protected]'
  17. });
  18. // Alert (p1.get ('age '));
  19.  
  20. // 3 Ext. modelmgr. Create
  21. VaR P2 = ext. modelmgr. Create ({
  22. Name: 'baomengjie ',
  23. Age: 23,
  24. Email: '[email protected]'
  25. }, "User ");
  26. Alert (p2.get ('email '));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.