extjs model store學習筆記

來源:互聯網
上載者:User

標籤:html   通過   lin   orm   查詢   can   sencha   htm   fine   

http://docs.sencha.com/extjs/6.2.0/guides/core_concepts/data_package.html

// 定義一個Model
Ext.define(‘MyApp.model.User‘, { extend: ‘Ext.data.Model‘, fields: [ {name: ‘name‘, type: ‘string‘}, {name: ‘age‘, type: ‘int‘} ]});

 

// 定義一個store
Ext.define(‘MyApp.store.Users‘, { extend: ‘Ext.data.Store‘, alias: ‘store.users‘, model: ‘MyApp.model.User‘, data : [ // Stores can also load data in-line. Internally, Store converts each of the objects we pass in as data into records of the appropriate Model type: {firstName: ‘Seth‘, age: ‘34‘}, {firstName: ‘Scott‘, age: ‘72‘}, {firstName: ‘Gary‘, age: ‘19‘}, {firstName: ‘Capybara‘, age: ‘208‘} ]});

 

var store = Ext.create(‘Ext.data.ArrayStore‘, {    // store configs    storeId: ‘myStore‘,    // reader configs    fields: [ // 可以直接定義fields,不必定義model       ‘company‘,       {name: ‘price‘, type: ‘float‘},       {name: ‘change‘, type: ‘float‘},       {name: ‘pctChange‘, type: ‘float‘},       {name: ‘lastChange‘, type: ‘date‘, dateFormat: ‘n/j h:ia‘}    ],    data = [        [‘3m Co‘,71.72,0.02,0.03,‘9/1 12:00am‘],        [‘Alcoa Inc‘,29.01,0.42,1.47,‘9/1 12:00am‘],        [‘Boeing Co.‘,75.43,0.53,0.71,‘9/1 12:00am‘],        [‘Hewlett-Packard Co.‘,36.53,-0.03,-0.08,‘9/1 12:00am‘],        [‘Wal-Mart Stores, Inc.‘,45.45,0.73,1.63,‘9/1 12:00am‘]    ]    });

 

 
Model中定義的Proxy是針對該model的CURD進行的操作。是針對單條記錄的。也就是可以建立一個model的對象,通過proxy提交到後台
Store中定義的Proxy是針對model集合的查詢操作。

Models are typically used with a Store, which is basically a collection of records (instances of a Model-derived class)


extjs model store學習筆記

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.