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

How to sync a datasource?

4 Answers 361 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 05 Jan 2012, 01:56 AM
I have created a simple test to display a MySQL data table on a Kendo Grid using the DEMOS example as a template (ie, using a toolbar with Add/Edit/Cancel buttons, and having a Destroy command button in the grid).   I have defined my transport as:

transport: {
 read: {
                url: "services/user-read.php", 
                dataType: "JSON"
              },
              create: {
                url: "services/user-add.php", 
                type: "POST"
              },
              update: {
                url: "services/user-edit.php",
                type: "POST"
              } ,
 destroy: {
                url: "services/user-delete.php",
                type: "POST"
              }
},


During use, the Grid lets me Add / Edit and Delete records (and initially READS records just fine).   However, my Create/Update/Destroy PHP's never get called.   Is there something I have to manually do to get a Datasource to call these functions?   Any good examples of this available?

Thanks in advance!




4 Answers, 1 is accepted

Sort by
0
Andrew
Top achievements
Rank 1
answered on 05 Jan 2012, 04:29 AM
Update.  Problem with most of it was an error in my PHP scripts.   READ / CREATE and UPDATE now fire properly.   

DESTROY still does not and I am open to any ideas.  Grid is created with this part defining the buttons (same as DEMO sample), so not sure why it is not firing the destroy handler defined in the transport...

...
toolbar: ["create", "save", "cancel"],
columns:[
 { field: "user_name", title: "Username" },
 { field: "password", title: "Password" },
 { field: "display_name", title: "Display Name" },
 { command: "destroy", title: " ", width: "110px" }
], 

...
0
Andrew
Top achievements
Rank 1
answered on 05 Jan 2012, 05:44 AM
Ok, figured out my own mess.   Delete event in Transport does not fire until a user also presses SAVE CHANGES - at which point the queued up deletes go one after another...
0
Jonas
Top achievements
Rank 1
answered on 23 Jan 2012, 01:51 PM
Stumbled on this too, I dont think it's very intuitive to demand the user to click on "save" after "destroy" (and he already clicked confirm). Should be an option. Is it already?
0
Lito
Top achievements
Rank 1
answered on 15 Nov 2013, 05:38 AM
Hi,

My Grid sync with my MySQL datasource for read and update. But I cannot sync for Delete (destroy) and Add.
I am sure what the db connection code should look like. Could you please share me your

url: "services/user-delete.php",
and 
  url: "services/user-add.php", 

I was expecting that there will be a DROP query in delete.php and and INSERT query in the add.php. Is that correct?

My Grid looks like this:

arrowscorenow.com/asn_batch/select_archers.php

The Grid itself seems to work but the MYSQL DB does not sync for delete and add.

Thanks.
Tags
Data Source
Asked by
Andrew
Top achievements
Rank 1
Answers by
Andrew
Top achievements
Rank 1
Jonas
Top achievements
Rank 1
Lito
Top achievements
Rank 1
Share this question
or