我将http://js-grid.com用于我的 php 应用程序。我选择这个库进行内联编辑/更新/添加/删除。现在我想查看来自数据库的数据$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
rendering的属性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
致谢。