博士剑道UI与数据源(CRUD)
Php Kendo UI With datasource (CRUD)
我正在努力使用Kendo UI获得CRUD的功能?我的创建和更新选项似乎不起作用,但我的阅读起作用,有什么帮助吗?我已经学习了很多教程,但就是无法让它发挥作用。提前谢谢。
这里是我的代码,这是我的Index.php文件:
<!DOCTYPE html>
<html>
<head>
<link href="styles/kendo.common.min.css" rel="stylesheet" />
<link href="styles/kendo.default.min.css" rel="stylesheet" />
<link href="styles/kendo.dataviz.min.css" rel="stylesheet" />
<link href="styles/kendo.dataviz.default.min.css" rel="stylesheet" />
<script src="js/jquery.min.js"></script>
<script src="js/angular.min.js"></script>
<script src="js/kendo.all.min.js"></script>
</head>
<body>
<div id="example">
<div id="grid"></div>
<script>
$(document).ready(function () {
dataSource = new kendo.data.DataSource({
batch: true,
transport: {
read: "data/ussd.php"
},
update: {
url: "data/ussd.php",
type: "POST"
},
create: {
url: "data/create.php",
type: "PUT"
},
parameterMap: function(options, operation){
if(operation !== "read" && option.models){
return{models : kendo.string(options.models)}
}
},
pageSize: 20,
schema: {
data: "data",
model: {
id: "id",
fields: {
id: {editable: false, nullable: true},
msisdn: {editable: true, type: "number"},
company: {editable: true},
description: {editable: true},
ussd: {editable: true},
updated: {editable: true, type: "date"},
added: {editable: true, type: "date"}
}
}
},
serverFiltering: true,
serverSorting: true
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
filterable: true,
sortable: true,
height: 500,
toolbar: ["create", "save", "cancel"],
columns: [
{ field: "id", title: "ID", width: "45px" },
{ field: "msisdn", title: "MSISDN", width: "75px" },
{ field: "company", title: "Company", width: "100px" },
{ field: "description", title:"Description", width: "100px" },
{ field: "ussd", title: "USSD", width: "100px" },
{ field: "updated", title: "Updated", width: "100px" },
{ field: "added", title: "Added", width: "100px" },
{ command: ["edit", "destroy"], title: " ", width: "140px" }],
schema: {
model: { id: "id" }
},
editable: "inline",
navigable: true
});
});
</script>
</div>
</body>
</html>
这就是我所改变的,基本上URL和类型是不正确的,并且没有遵循正确的路径
$(document).ready(function () {
dataSource = new kendo.data.DataSource({
transport: {
read: "data/whitelist.php?type=read",
update: {url:"data/whitelist.php?type=update", type:"POST"},
create: {url:"data/whitelist.php?=create",type:"POST"},
destroy: {url:"data/whitelist.php?type=destroy",type:"POST"}
},
batch: false,
pageSize: 20,
schema: {
model: {
id: "id",
fields: {
id: {editable: false, nullable: true},
msisdn: {editable: true, type: "number"},
company: {editable: true},
description: {editable: true},
ussd: {editable: true},
updated: {editable: true, type: "date"},
added: {editable: true, type: "date"}
}
}
},
serverFiltering: true,
serverSorting: true
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
filterable: true,
sortable: true,
height: 430,
toolbar: [{name: "create", text: "Add New"}, "save", "cancel"],
columns: [
{ field: "id", title: "ID", width: "26px" },
{ field: "msisdn", title: "MSISDN", width: "50px" },
{ field: "company", title: "Company", width: "65px" },
{ field: "description", title:"Description", width: "65px" },
{ field: "ussd", title: "USSD", width: "50px" },
{ field: "updated", title: "Updated", width: "70px" },
{ field: "added", title: "Added", width: "70px" },
{ command: [{text:"Edit", name:"edit"}, {text:"Delete",name:"destroy"}], title: " ", width: "80px" }],
editable: "inline",
navigable: true
});
});
{ read: "data/ussd.php"
},
update: {
url: "data/ussd.php",
type: "POST"
},
create: {
url: "data/create.php",
type: "PUT"
}
您的Read和update都使用相同的php文件。
create中的PUT
类型是什么?
只需将更新url更改为其他php文件,并获取发布的值即可在数据库中运行查询。并将create的类型也更改为POST,因为你也在为其他人使用POST。。
在更新部分更改此
url: "data/ussd.php",
进入
url: "data/update.php",
并尝试获取我之前说过的发布值。看看是否适合你。
相关文章:
- Datatables:通过DOM数据源中的名称引用列
- 如何将JSON数据源适合Jquery自动完成小部件
- SmartGWT数据源和CORS
- 带有变量的Angular.js数据源
- 在远程数据源调用之前,将筛选器注入数据源
- $http.delete回调未在基本CRUD应用程序中启动
- Kendo UI网格:数据源刷新后,我丢失了分页
- 使用angularJs中的数据库数据源刷新下拉列表
- 是否可以在不使用外部后端的情况下编写grafana数据源插件
- 使用angularJS进行CRUD操作
- Meteor将CRUD操作限制为管理员或文档所有者
- 谷歌图表可视化仪表板数据源问题
- 如何在telerik剑道移动应用程序中按下刷新数据源的按钮
- 如何制作Kendo MVC Helpers's使用JSON作为contentType的CRUD
- CRUD with ExpressJS router
- 剑道数据源,将动态数据发送到服务器
- 如何在剑道中设置 CRUD 工作
- imacros JavaScript 数据源行循环
- 具有 OData 格式的 kendo 网格数据源 = json
- 博士剑道UI与数据源(CRUD)