Model学习笔记

来源:互联网 发布:windows 后门 编辑:程序博客网 时间:2024/04/29 20:21

1. 通过regModel来注册一个新Model:

Ext.regModel('NoteModel',{//use define instead of regModel in ST 2.0idProperty: 'id',// default is also 'id'fields:[{name: 'id', type: 'int'},{name: 'date', type:'date', dateFormat: 'c'},{name: 'title', type: 'string'},{name: 'narrative', type: 'string'}],validation:[{type: 'presence', field: 'id'},{type: 'presence', field: 'title', message: 'Please enter a title for this note.'}]});

这个model名字为 NoteModel, 连接自动生成的namespace,整个名字为 “NotesApp.models.NoteModel”。 idProperty设置主键,默认为id字段。