0

PHP アプリケーションにhttp://js-grid.comを使用しています。インライン編集/更新/追加/削除用にこのライブラリを選択します。$variablesここで、データベースから取得されるデータを表示したいと考えて$arrayいます。ここにスクリプトがあります

<script>
    $(function() {
        $("#jsGrid").jsGrid({
            pageButtonCount: 5,
            deleteConfirm: "Do you really want to delete the client?",
            controller: db,
            fields: [
                { name: "Name", type: "text", width: 150 },
                { name: "Age", type: "number", width: 50 },
                { type: "control" }
            ]
        });

    });
</script>

controller上記のコードでは、 renderというプロパティを取得しましたdb (data)dbファイルから来ていますdb.js。ファイルは次のようになります。

(function() {
var db = {
    loadData: function(filter) {
        return $.grep(this.clients, function(client) {
            return (!filter.Name || client.Name.indexOf(filter.Name) > -1)
                && (!filter.Age || client.Age === filter.Age)
                && (!filter.Address || client.Address.indexOf(filter.Address) > -1)
                && (!filter.Country || client.Country === filter.Country)
                && (filter.Married === undefined || client.Married === filter.Married);
        });
    },
    insertItem: function(insertingClient) {
        this.clients.push(insertingClient);
    },
    updateItem: function(updatingClient) { },
    deleteItem: function(deletingClient) {
        var clientIndex = $.inArray(deletingClient, this.clients);
        this.clients.splice(clientIndex, 1);
    }
};

window.db = db;

db.countries = [
    { Name: "", Id: 0 },
    { Name: "United States", Id: 1 },
];

db.clients = [
    {
        "Name": "Otto Clay",
        "Age": 61,
    },
    {
        "Name": "Connor Johnston",
        "Age": 73,
    }
];

}()); 

また、github ドキュメントhttps://github.com/tabalinas/jsgrid-phpに従いました。しかし、私php $variable or $arrayは自分のビューとjavaScripts.

したいこと:$array javaScripts のセクションに を呼び出したいcontroller : db

エラー:controller: <?php echo $array; ?>', its returning null cause I can not call as they called as default from db.js` を使用すると

事前に 感謝するphp $variable or $arrayのではなく、どうすれば電話できるか教えてください。controller: dbjavaScript

4

1 に答える 1