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: db
javaScript