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

CRUD with CakePHP

0 Answers 258 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Claudio
Top achievements
Rank 1
Claudio asked on 08 Mar 2012, 02:07 AM
Good evening, i'm trying KendoUI and i have to say it is really amazing! So, first, i'd like to thank you for your excellent work.

As the title says, i'm developing a server-side cakephp application, and i'm using kendoGrid for client-side "presentation layer".

My issue comes when i try to make CRUD operations. By the way, reading is ok, i can read the json data and show it up without problems. My problems start when trying to update (haven't tried to create/delete yet, so it doesn't matter right now).

The JSON response y get from my controller have this structure:

[{"Microcampamento":{"id":"-1","mc_nombre":ninguno)",
"mc_calle_nombre":"","mc_calle_numero":"0","mc_comuna":"0","mc_anoest":"0000","mc_int_inicio":"0000-00-00","mc_int_fin":"0000-00-00","idfase":"0","mc_email_equipo":"nl","mc_comollegar":"null","mc_rasofac":"null","mc_bbdd":"null"}},{"Microcampamento":{"id":"1","mc_nombre":"4 Canchas","mc_calle_nombre":"Calle diecinueve","mc_calle_numero":"1118","mc_comuna":"118","mc_anoest":"2003","mc_int_inicio":"2010-01-01","mc_int_fin":"0000-00-00","idfase":"4","mc_email_equipo":"cnovoa@segen.cl","mc_comollegar":"null","mc_rasofac":"null","mc_bbdd":"null"}},
{"Microcampamento":{"id" ....and the other fields......}}]

ds=new kendo.data.DataSource({
                transport:{
                    read:{
                        url:"/FTC/microcampamentos/crud",
                        dataType: "json",
                        complete: function(jqXHR, textStatus) {
                            console.log(textStatus, "read") }
                        }
                    },
                    update:{
                        url: "/FTC/microcampamentos/crud",
                        type: "POST",
                        complete: function(jqXHR, textStatus) {
                            console.log(textStatus, "update")
                        }
                    },
                    parameterMap: function(options, operation) {
                    },
                change: function(){
                    console.log("Something happened!")
                },
                error: function() {
                    alert("Ha ocurrido un error al intentar conectar con la base de datos.");
                },
                schema: {
                    model:{
                        id:"Microcampamento.id",
                        fields:{
                                'Microcampamento.id':               {editable:false},
                                'Microcampamento.mc_nombre':        {editable:true},
                                'Microcampamento.mc_calle_nombre':  {editable:true},
                                'Microcampamento.mc_calle_numero':  {editable:true},
                                'Microcampamento.mc_comuna':        {editable:true},
                                'Microcampamento.mc_anoest':        {editable:true},
                                'Microcampamento.mc_int_inicio':    {editable:true},   
                                'Microcampamento.mc_int_fin':       {editable:true},       
                                'Microcampamento.idfase':           {editable:true},           
                                'Microcampamento.mc_email_equipo':  {editable:true},
                                'Microcampamento.mc_comollegar':    {editable:true},   
                                'Microcampamento.mc_rasofac':       {editable:true},   
                                'Microcampamento.mc_bbdd':          {editable:true}                
                        }
                    }
                },
                pageSize:10
        });

And my kendoGrid is initiallized like this:

$(document).ready(function(){
            //KendoGrid para Microcampamentos
            $("#mc_grid").kendoGrid({
                    dataSource:ds,
                    height: 370,
                    scrollable:false,
                    sortable: true,
                    pageable: true,
                    editable: true,
                    navigatable: true,
                    toolbar: ["create", "save", "cancel","destroy"],
                    columns: [
                            {field: "Microcampamento.id",       title: "ID"},
                            {field: "Microcampamento.mc_nombre",    title: "Nombre"},
                            {field: "Microcampamento.mc_calle_nombre",  title: "Calle"},
                            {field: "Microcampamento.mc_calle_numero",  title: "Número"},
                            {field: "Microcampamento.mc_comuna",    title: "Comuna"},
                            {field: "Microcampamento.mc_anoest",    title: "Año Est."},
                            {field: "Microcampamento.mc_int_inicio",    title: "Inicio Interv."},
                            {field: "Microcampamento.mc_int_fin",   title: "Fin Interv."},
                            {field: "Microcampamento.idfase",       title: "Fase", width: '100px'},
                            {field: "Microcampamento.mc_email_equipo",  title: "Email Equipo"},
                            {field: "Microcampamento.mc_comollegar",    title: "Cómo Llegar", template:'<a href="" >IR</a>'},
                            {field: "Microcampamento.mc_rasofac",   title: "Rasofac"},
                            {field: "Microcampamento.mc_bbdd",      title: "BBDD"}
 
                    ]  
            })
    });

With the code just like i just show you, i get no data posted to server-side. I see that with firebug and debuging my php code.
Here's an screenshot-> Update Error 1

If i don't set parametermap, i get an error message from kendo.all.js -> Update Error 2
In this same situation, if i click on "Add new record" i got this error -> Create Error 1

So, i understand the problem is setting the parametermap property, so i have to define it, but i don't know how to do it, to make it work with CakePHP.

I really appreciate your help.

Thank you very much in advance!

No answers yet. Maybe you can help?

Tags
Data Source
Asked by
Claudio
Top achievements
Rank 1
Share this question
or