Hi, I have the following problem and do not know how to fix it, do not leave me buttons to edit, delete the command. please help. and excuse my English
I leave the files you work
<script>
$(document).ready(function () {
var crudServiceBaseUrl = "editing.php",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "?type=read",
contentType: "application/json; charset=utf-8",
type:"POST"
},
update: {
url: crudServiceBaseUrl + "?type=update",
contentType: "application/json; charset=utf-8",
type:"POST"
},
destroy: {
url: crudServiceBaseUrl + "?type=destroy",
contentType: "application/json; charset=utf-8",
type:"POST"
},
create: {
url: crudServiceBaseUrl + "?type=create",
contentType: "application/json; charset=utf-8",
type:"POST"
},
parameterMap: function(data) {
return kendo.stringify(data);
}
},
batch: true,
pageSize: 20,
schema: {
data: "data",
model: {
id: "ProductID",
fields: {
ProductID: { editable: false, nullable: true },
ProductName: { validation: { required: true } },
UnitPrice: { type: "number", validation: { required: true, min: 1} },
Discontinued: { type: "boolean" },
UnitsInStock: { type: "number", validation: { min: 0, required: true } }
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 550,
toolbar: ["create","save"],
columns: [
{ field:"ProductName", title: "Nombre del Producto" },
{ field: "UnitPrice", title:"Precio Unitario", format: "{0:c}", width: "120px" },
{ field: "UnitsInStock", title:"Unidades", width: "120px" },
{ field: "Discontinued",title:"Disponible", width: "120px" },
{ command: ["edit", "destroy"], title: " ", width: "250px" }],
editable: "popup"
});
});
</script>
php.editing
<?php
require_once '../lib/DataSourceResult.php';
require_once '../lib/Kendo/Autoload.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
header('Content-Type: application/json');
$request = json_decode(file_get_contents('php://input'));
$result = new DataSourceResult('mysql:host=localhost;dbname=northwind;charset=utf8', 'root', 'jp72240');
$type = $_GET['type'];
$columns = array('ProductID', 'ProductName', 'UnitPrice', 'UnitsInStock','Discontinued');
switch($type) {
case 'create':
$result = $result->create('products', $columns, $request->models, 'ProductID');
break;
case 'read':
$result = $result->read('products', $columns, $request);
break;
case 'update':
$result = $result->update('products', $columns, $request->models, 'ProductID');
break;
case 'destroy':
$result = $result->destroy('products', $request->models, 'ProductID');
break;
}
echo json_encode($result,JSON_NUMERIC_CHECK);
exit;
}
?>