This is a migrated thread and some comments may be shown as answers.

undefined grid command

1 Answer 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
nada
Top achievements
Rank 1
nada asked on 18 Jul 2015, 06:31 PM

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: "&nbsp;", 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;

}
?>​

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 22 Jul 2015, 06:12 AM
Hello Nada,

I am not able to reproduce the described problem with the provided code. Can you send a complete runnable demo or modify this one, until the issue is exhibited?

http://dojo.telerik.com/Ufoqi/2

On a side note, you only need a "Save" button with in-cell editing.

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
nada
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or