[英]Kendo UI dataSource transport calling php function
問候大家,
如果我的代碼中有此category.php文件,則可以執行CRUD功能。 但是,在Kendo UI dataSource中,如何在數據源/傳輸中調用這些函數? 在此之前,我曾經將php文件拆分過,但是現在我只想放入一個文件中。 誰能幫我? 感謝您的時間。
<?php
class Categories {
function getCategory(){
//codes in here
}
function addCategory(){
//codes in here
}
function editCategory(){
//codes in here
}
function deleteCategory(){
//codes in here
}
}
?>
transport: {
read: {
url: "./category.php", // <---calling getCategory function
type: "POST",
data: function() {
return {
c1: document.getElementById('c1').checked,
}
},
},
create: {
url: "./category.php", // <---calling addCategory function
type: "POST",
complete: function (e) {
$('#grid').data('kendoGrid').dataSource.read();
}
},
update: {
url: "./category.php", // <---calling editCategory function
type: "POST",
complete: function (e) {
$('#grid').data('kendoGrid').dataSource.read();
}
},
destroy: {
url: "./category.php", // <---calling deleteCategory function
type: "POST",
complete: function (e) {
$('#grid').data('kendoGrid').dataSource.read();
}
},
},
最后繞圈,我需要在我的php文件中添加method()
,然后在我的dataSource / transport上需要向該方法返回值data: {method: "addCategory"},
下面的示例。
<?php
$method = $_POST['method'];
$method();
class Categories {
function getCategory(){
//codes in here
}
function addCategory(){
//codes in here
}
function editCategory(){
//codes in here
}
function deleteCategory(){
//codes in here
}
}
?>
transport: {
read: {
url: "category.php",
type: "POST",
data: function() {
return {
method: "getCategory",
c1: document.getElementById('c1').checked,
}
},
},
create: {
url: "category.php",
type: "POST",
data: {method: "addCategory"},
complete: function (e) {
$('#grid').data('kendoGrid').dataSource.read();
}
},
update: {
url: "category.php",
type: "POST",
data: {method: "editCategory"},
complete: function (e) {
$('#grid').data('kendoGrid').dataSource.read();
}
},
destroy: {
url: "category.php",
type: "POST",
data: {method: "deleteCategory"},
complete: function (e) {
$('#grid').data('kendoGrid').dataSource.read();
}
},
},
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.