因此,我真的很难让jsGrid在我的Django站点上运行,特别是使用控制器从ajax请求加载表中的数据。它没有工作,所以我设置了这个非常基本的配置,只想看看我的控制器中的loadData函数是怎么回事。使用下面的配置,控制台中打印的唯一内容是"In Script“。因此,它显然不是在控制器中调用loadData。也许这个简单的“测试”配置也不正确。拜托,我在这里少了什么?一定是些愚蠢的事。
{% extends 'layouts/layout_1.html' %}
{% block title %}Demos{% endblock %}
{% block content%}
<div id="demos-js-grid"></div>
{% endblock %}
{% block other_js %}
<script>
$(document).ready(function() {
console.log("In Script.")
$("#demos-js-grid").jsGrid({
onDataLoading: function(args) {
console.log("On Data loading.")
},
width: "100%",
height: "100%",
inserting: true,
editing: true,
sorting: true,
autoLoad: true,
controller: {
loadData: function(filter) {
console.log("loadData being called..");
},
insertItem: function(item) {
console.log("insertItem being called..")
},
updateItem: function(item) {
console.log("updateItem being called..")
},
deleteItem: function(item) {
console.log("deleteItem being called..")
}
},
fields: [
{ name: "Client Status", type: "text", width: 50 },
{ name: "Bee Status", type: "text", width: 50 },
{ name: "Store Status", type: "text", width: 50 },
{ name: "Region", type: "text", width: 100 },
{ name: "Chain", type: "text", width: 100 },
{ name: "Store", type: "text", width: 150 },
]
});
})
</script>
{% endblock%}发布于 2016-12-03 22:24:08
选项应该是autoload: true,而不是autoLoad。
事实上,由于当前没有激活自动加载,所以网格没有加载,但是您仍然可以自己调用loadData方法加载它。
https://stackoverflow.com/questions/40952502
复制相似问题