使用代码点火器的剑道ui网格crud


kendo ui grid crud with codeigniter

  1. 请帮助我使用代码点火器控制器的剑道网格样本

    我的看法

    $("#grid").kendoGrid({
    dataSource: {
        transport: {
            read: {
                url: 'schoolC/crud',
                contentType: 'application/json'
            },
            create: {
                url: 'schoolC/crud',
                type: "PUT",
                datatype: 'json'
            },
            update: {
                url: 'schoolC/crud',
                type: "POST",
                datatype: 'json'
            },
            destroy: {
                url: 'schoolC/crud',
                type: "POST",
                datatype: 'json'
            }                                
        },
        error: function(e) {
                alert(e.responseText);
            },
        schema: {
            data: "data",
            id: "school_id",
            model: {
                fields: {
                    school_name: { 
                        type: "string",
                        validation: { required: true }
                    }
                }
            }
        },
        pageSize: 10
    },
    height: 400,
    batch: false,
    scrollable: true,
    sortable: true,
    filterable: true,
    resizable: true,
    toolbar: ['create'],
    editable: "popup",
    pageable: {                            
        numeric: true,
        refresh: true,
        pageSizes: true
    }, 
    columns: [
        {
            field: "school_name",
            title: "School Name",                                
            width: 100
        },
        { command: ["edit", "destroy"], title: " ", width: "210px" }                            
    ]
    

    });

    控制器方法

    function crud()
    {
        header("Content-type: application/json");
        switch($_SERVER["REQUEST_METHOD"])
        {
            case 'GET':
                echo $this->SchoolM->get_allJsonData(); 
            break;
            case 'PUT':
                echo $this->SchoolM->addSchoolInfo(array('school_name'=> mysql_real_escape_string($_POST["school_name"])));
            break;
            case 'POST':
                echo $this->SchoolM->updateSchoolInfo(array('school_name'=> mysql_real_escape_string($_POST["school_name"])), array('school_id'=> mysql_real_escape_string($_POST["school_id"])));
            break;
            case 'DELETE':
                echo $this->SchoolM->deleteSchool(mysql_real_escape_string($_POST["school_id"]));               
            break;
        }
    }
    

    模型方法

    function get_allJsonData()
    {
        $arr = array();
        $this->db->from('school');
        $this->db->order_by("school_name", "asc");
        $query = $this->db->get();
        foreach($query->result_object() as $rows )
        {
            $arr[] = $rows;
        }
        return "{'"data'":" .json_encode($arr). "}";
    }
    function addSchoolInfo($school_name)
    {
        return json_encode($this->db->insert('school',$school_name));
    } 
    function updateSchoolInfo($school_date, $condition)
    {
        return json_encode($this->db->update('school', $school_date, $condition));
    }
    function deleteSchool($school_id)
    {
        $this->db->where_in('school_id',$school_id);
        return json_encode($this->db->delete('school'));
    }   
    

    我正在使用codeigniter它读取,但其余的创建更新和删除都不能正常工作。它还添加了许多空行作为每个创建操作中的行大小。pls帮助我

抱歉不懂英语,在这里自动翻译这个工作,哈哈。但我想我可以帮助你,你正在努力让他们的电话在你的网格中CRUD?

我所做的是用同一个调用创建所有的调用,但使用一个GET,如果通过引用传递,则表示将要执行的操作。请参阅下面的示例。

$("#grid").kendoGrid({
        dataSource: {
            transport:{
                read: "CRUD.client.php?func=read",
                create: {
                    url: "CRUD.client.php?func=create",
                    type: "POST"
                },
                update: {
                    url: "CRUD.client.php?func=update",
                    type: "POST"
                },
                destroy: {
                    url: "CRUD.client.php?func=delete",
                    type: "POST"
                }
            },

注意,一旦文件(所有文件都是一样的(有了一个传递参数,php将读取该参数,并通过if.决定谁将执行execudado警报

if ($verb == "GET" && $func == "read") {code CRUD here}

我帮了忙!!!