Sencha touch Json Data仅显示2条记录

时间:2012-02-17 07:56:06

标签: sencha-touch

我刚用Sencha touch List和Json读者创建了一个小应用程序。有超过30条记录,但它只显示2条数据记录。

以下是代码:

    Ext.regModel('Story', {
        idProperty: 'story_id',
        fields: [
            {name: "story_id",          type: "int"},
            {name: "id",                type: "int"},
            {name: "category_id",       type: "int"},
            {name: "story_content",     type: "string"},
            {name: "image",          type: "string"},
            {name: "story_posted_on",   type: "date"},
        {name: "story_modified_on", type: "date"},
            {name: "active_status",     type: "int"}
        ]
    });

    Ext.regStore('StoryStore', { 
        model: 'Story',
        sorters: [{
            property: 'story_posted_on',
            direction: 'DESC' 
        }],
        autoLoad: true,
        proxy: {
            type: 'ajax', 
            url: '../backend/index.php?r=stories/getStories',
        },
        reader: {
            type: 'json',
        }
    });


    App.views.FMJList = new Ext.List({
        id: 'FMJList',
        store: 'StoryStore',
        itemTpl: '<div class="story">'+
            '<div class="story_content">'+
                '<tpl if="image">'+
                    '<div class="story_img" style="background-image: url(http://localhost/app/uploads/stories/{image});"></div>'+
                '</tpl>'+
                '<div class="story_content">{story_content}</div>'+
                '<div class="story_display_name">{id}</div>'+
            '</div>'+
        '</div>'
    });

有什么想法吗?提前谢谢。

以下是Json的回复:

[

{
story_id: "193",
id: "4",
category_id: "74",
story_content: "testing",
image: "1328009566.png",
story_liked: "0",
story_empathy: "0",
story_deserve: "0",
story_posted_on: "2012-01-31 07:32:46",
story_modified_on: "2012-02-01 05:21:11",
active_status: "2"
},
{
story_id: "194",
id: "4",
category_id: "74",
story_content: "test",
image: "",
story_liked: "0",
story_empathy: "0",
story_deserve: "0",
story_posted_on: "2012-02-01 12:48:43",
story_modified_on: "2012-02-01 05:19:16",
active_status: "2"
},
{
story_id: "195",
id: "4",
category_id: "74",
story_content: "face",
image: "",
story_liked: "0",
story_empathy: "0",
story_deserve: "0",
story_posted_on: "2012-02-01 06:59:24",
story_modified_on: "2012-02-01 06:59:24",
active_status: "1"
},
{
story_id: "196",
id: "4",
category_id: "74",
story_content: "testing image",
image: "",
story_liked: "0",
story_empathy: "0",
story_deserve: "0",
story_posted_on: "2012-02-01 07:07:59",
story_modified_on: "2012-02-01 07:10:29",
active_status: "2"
},
{
story_id: "197",
id: "1",
category_id: "74",
story_content: "update image",
image: "",
story_liked: "0",
story_empathy: "0",
story_deserve: "0",
story_posted_on: "2012-02-01 07:11:49",
story_modified_on: "2012-02-01 07:11:49",
active_status: "1"
},
{
story_id: "198",
id: "1",
category_id: "74",
story_content: "testing",
image: "1328094802.jpg",
story_liked: "0",
story_empathy: "0",
story_deserve: "0",
story_posted_on: "2012-02-01 07:13:22",
story_modified_on: "2012-02-01 07:15:09",
active_status: "2"
},
{
story_id: "199",
id: "4",
category_id: "74",
story_content: "teste",
image: "1328178474.jpg",
story_liked: "0",
story_empathy: "0",
story_deserve: "0",
story_posted_on: "2012-02-02 10:27:54",
story_modified_on: "2012-02-02 10:27:54",
active_status: "1"
},
{
story_id: "200",
id: "4",
category_id: "74",
story_content: "test",
image: "",
story_liked: "0",
story_empathy: "0",
story_deserve: "0",
story_posted_on: "2012-02-02 10:32:18",
story_modified_on: "2012-02-02 10:32:18",
active_status: "1"
},
{
story_id: "201",
id: "4",
category_id: "74",
story_content: "test again",
image: "",
story_liked: "0",
story_empathy: "0",
story_deserve: "0",
story_posted_on: "2012-02-02 10:32:40",
story_modified_on: "2012-02-02 10:32:40",
active_status: "1"
}]

发现问题实际上是idProperty:'story_id'。 idProperty默认设置为id并且它是唯一的,idProperty不会覆盖我认为的默认值。有人知道修复的方法吗?

0 个答案:

没有答案