1

I've coded a small mobile application using Sencha Touch 2 framework. For the moment, I manage some articles from a database in localhost. I've written a database management using PHP CRUD methods contained here in ArticleService.php file. My 'read' fonction get back all the articles. But I want to have an other 'read' method to read for exemple a specific article according to its id or the last 5 articles, etc. But the store proxy (I think so) allows 1 methods for each main operation. So in my case, for 'read' operation I just have an only 'read' method.

Here's is my 'store' source code :

Ext.define("MyApp.store.ArticleStore", {
    extend: "Ext.data.Store",
    requires: ["MyApp.model.ArticleModel"],
    config: {
    model: "MyApp.model.ArticleModel",
    proxy: {
        type: "ajax",
        api: {
            create: "http://localhost/MobileApplication/MyApp/services/ArticleService.php?action=create",
            read: "http://localhost/MobileApplication/MyApp/services/ArticleService.php?action=read",
            update: "http://localhost/MobileApplication/MyApp/services/ArticleService.php?action=update",
            destroy: "http://localhost/MobileApplication/MyApp/services/ArticleService.php?action=destroy"
        },
         extraParams: {
            keyword: ""
        },
        reader: {
            type: "json",
            rootProperty: "articles",
            totalProperty: "total"
        }
    },
        autoLoad: true
    }
});

Is there a possible way to have several methods for each main CRUD operation (for example 3 differents 'read' methods to manage my articles display) ? I'm really lost. Thanks in advance for your help!

4

1 回答 1

0

您不需要不同的读取方法。加载存储后,它将在内存中,您将能够找到所需的任何记录。

如果您的商店太大而无法立即加载 - 请查看remoteFilter属性:http ://docs.sencha.com/touch/2.1.1/#!/api/Ext.data.Store-cfg-remoteFilter这样,您将设置的过滤器(如 id = 1 或 parent_id = 2)将被传递到服务器,以便它可以返回正确的记录集。

于 2013-05-28T16:35:36.227 回答