html側
<script>
kendo.culture("ja-JP");
$(document).ready(function () {
var dataSource = new kendo.data.DataSource({
transport: {
read: { url: "./data/Customer.php", type: "GET", datatype: "json" },
destroy: {
url: "./data/Customer.php", type: "POST", datatype: "json"
},
parameterMap: function (data, type) {
return kendo.stringify(data);
}
},
error: function (e) {
alert("Status: " + e.status + "; Error message: " + e.errorThrown);
},
batch: true,
schema: {
model: {
id: "KosID",
fields: {
KosID: { editable: false, nullable: true, type: "number" },
KosName: {}
}
},
data: 'data',
total: 'total'
},
pageSize: 10
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageSize: 10,
height: 550,
filterable: true,
sortable: true,
selectable: false,
pageable: {
refresh: false,
pageSizes: true,
buttonCount: 5
},
columns: [
{ field: "KosID", title: "顧客No", filterable: false },
{ field: "KosName", title: "顧客名称", filterable: false },
{ command: "destroy", title: " ", width: 100 }
],
editable: "inline"
});
});
</script>
php側
<?php
require_once '../lib/DataSourceResult.php';
require_once '../lib/kendo/Autoload.php';
require_once "db_Config.php";
$verb = $_SERVER['REQUEST_METHOD'];
if ($verb == 'GET') {
$result = new DataSourceResult(DB_STRING, DB_USER, DB_PASSWORD);
$columns = array('KosID', 'KosName');
$result = $result->read('kos', $columns, null);
header('Content-Type: application/json');
echo json_encode($result, JSON_NUMERIC_CHECK);
}
if ($verb == 'POST') {
$request = json_decode(file_get_contents('php://input'));
$result = new DataSourceResult(DB_STRING, DB_USER, DB_PASSWORD);
$result = $result->destroy('kos', $request->models, 'KosID');
}
?>
削除のサンプルがなかなか無かったので、苦労しました
0 件のコメント:
コメントを投稿