2011-08-24 44 views
1

我有一個簡單的列表,從JSON商店加載數據。我已經將分頁解析爲服務器端,因此爲了獲得新頁面,我更改了商店的代理並將頁面參數設置爲+1(新頁面),加載商店,並且列表僅顯示來自新一頁。 是否有可能使該列表在商店加載後追加新的結果?因此,當我用新數據加載商店時,我希望列表保留舊數據並添加新數據。 如果需要的話,我可以在代碼中展示它,但它非常自我描述。 謝謝。Sencha觸摸列表追加商店加載新結果

//編輯

目前我店裏是這樣的:

realio.stores.results = new Ext.data.Store({ 
    model: "realio.models.Results", 
    proxy: { 
     type: 'ajax', 
     url: 'http://site.com/json_list2.php?a=l&zp=1&u='+settings["ulica"]+'&c0='+settings["cena0"]+'&c1='+settings["cena1"]+'&p0='+settings["plocha0"]+'0&p1='+settings["plocha1"]+'&cm20='+settings["cenam20"]+'&cm21='+settings["cenam21"]+'&pg=0&s=Datumu&t='+settings["typ"]+'&age='+settings["stari"]+'&pod='+settings["podlazi"]+'&lat='+settings["lat"]+'&lng='+settings["lng"]+'&pp='+settings["pp"]+'&tp0='+settings["typ0"]+'&tp1='+settings["typ1"], 
     reader: { 
      type: 'json', 
      root: 'markers' 
     } 
    }, 
    sorters: [ 
     { 
      property: 'id', 
      direction: 'ASC' 
     } 
    ] 
}); 

和我的模型是這樣

realio.models.Results = Ext.regModel("realio.models.Results", { 
    fields: [ 
     {name: "titul", type: "string"}, 
     {name: "vlast", type: "string"}, 
     {name: "typb", type: "string"}, 
     ... 
    ] 
}); 

列表:

xtype: 'list', 
store: realio.stores.results, 
flex: 1, 
disableSelection: true, 
scroll: 'vertical', 
itemTpl: itemTemplate, 
onItemDisclosure: function (record) { 
    Ext.dispatch({ 
     controller: realio.controllers.detail, 
     action: 'load', 
     detail: record 
    }); 
}, 
listeners: { 
    'itemtap': function(t, i, it, e) { 
     Ext.dispatch({ 
      controller: realio.controllers.detail, 
      action: 'load', 
      detail: t.store.getAt(i) 
     }); 
    } 
}, 
plugins: [ 
    { 
     ptype: 'listpaging', 
     autoPaging: false 
    }, 
    { 
     ptype: 'pullrefresh' 
    } 
] 

我有尋呼解決了服務器端 - >當我在代理網址中設置& pg = x時,我轉到頁面x,所以我不知道如何讓它與這些商店頁面一起運行。即使我試圖設置商店頁面大小爲例如2,它會顯示所有結果無論如何,所以我認爲它不工作...

回答

0

有一個插件與Sencha Touch 1.1一起調用ListPagingPlugin,它可以讓你添加一個'加載更多「按鈕到列表的末尾,將讀取下一頁並追加數據。有一個例子(也包括),你可以在/ examples/pullrefresh中找到它(它與一個示例中的拉動刷新插件捆綁在一起)。

這個例子並不適用於我,因爲我認爲Twitter更改了它們的API,因此如果發送無效的頁面參數,它不會默認爲頁面1,而是告訴您 - 某些參數無效。爲了讓這個例子的工作,我不得不編輯/examples/pullrefresh/src/TwitterProxy.js線44 page: operation.pagepage: operation.page || 1

如果您有關於該插件的任何問題,你開始使用它,我們可以跨越特異性後當你到達那裏的橋= D

+0

嗨,我現在檢查它,我之前檢查過,但listpagingplugin正在與商店頁面。我現在不是真的如何讓他們工作。拉刷新的例子是相當混亂的嘰嘰喳喳代理我不認爲我需要做這麼複雜的代理,我會用一些代碼編輯主消息。 – haluzak

+0

再次看看TwitterProxy,你可以看到如何使用'Ext.apply'應用自定義參數(在pullrefresh示例中,他們在'buildRequest'中設置了2個自定義參數'rpp'和'page')做同樣的事情,但你的參數將是'pg' – chrixian

+0

@haluzak:你有任何進展。我在這裏完全相同的情況,並不能完全弄清楚Twitter的例子。 – keune

1

從我的經驗,我會做store.loadData(data,true);如果將數據附加到列表中已有的數據,則爲true。