2

Sencha Touch は初めてで、ボタンをクリックして項目を追加するリストを含むアプリ (Web アプリではなく、PhoneGap のネイティブ) を作成しようとしています。何日も探していましたが、役立つ解決策が見つかりません。

ハードコードされた値を自分のコードに入れる必要がないコードを変更するにはどうすればよいですか

data:[]
Ext.define('MyApp.store.Note', { 

extend: 'Ext.data.Store',
requires: ['MyApp.model.Note'],

config: {
model: 'MyApp.model.Note',

data:
[   
{id: 1, content: 'Blog 1', categoryid: 1, category: 'Nonsense' },
{id: 2, content: 'Blog 2', categoryid: 1, category: 'Nonsense' },
{id: 3, content: 'Blog 3', categoryid: 2, category: 'Food' }
],
}
});

私は自分のリストを作成しています

Ext.define('MyApp.view.NoteList',{
extend: 'Ext.dataview.List',
xtype: 'notelist',
config: {

    store: "Note", //will create the store later


    itemTpl: [
        '<div>',
        '    <div>{content}</div>',
        '    <p>{category}</p>',
        '</div>'
    ],
    onItemDisclosure: function(record,btn,index) {
        this.push(Ext.create('MyApp.view.RegisterPanel'));
        //when the little arrow on the right is tapped
    }
},
});
4

1 に答える 1

2

ストア インスタンスにアイテムを追加するだけです。

例:

var myStore = Ext.create('MyApp.store.Note');

//Use add with a config object
myStore.add({
   //your record here
   id: 1,
   content: "Blog 1",
   categoryid: 1,
   category: "Nonsense"
});

//Or create an instance of your record
var myRecord = Ext.create('MyApp.model.Note', {
   id: 1,
   content: "Blog 3",
   categoryid: 2,
   category: "Food"
});

//Add the record to the store
myStore.add(myRecord);
于 2013-07-03T09:26:43.967 に答える