Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sencha touch Sencha touch Json数据仅显示2条记录_Sencha Touch - Fatal编程技术网

Sencha touch Sencha touch Json数据仅显示2条记录

Sencha touch Sencha touch Json数据仅显示2条记录,sencha-touch,Sencha Touch,我刚刚用Sencha触摸列表和Json阅读器创建了一个小应用程序。有30多条记录,但仅显示2条数据记录 代码如下: Ext.regModel('Story', { idProperty: 'story_id', fields: [ {name: "story_id", type: "int"}, {name: "id", type: "int"},

我刚刚用Sencha触摸列表和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>'
    });

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

您能添加JSON响应吗?显示了哪些记录?显示了哪两个故事?我注意到的一点是,您将一些值读取为“int”,但将它们作为字符串发送(例如,story_id)。它返回最后一个值,并在第一个值之后返回第二个值。所以201和199。尝试在chrome控制台中输入Ext.getStore('StoryStore').getCount(),查看存储中有多少条记录。这将有助于将问题缩小到存储区或列表。可能与您的问题无关,但不应该引用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"
}]