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

Update and Delete not working in GRID

4 Answers 273 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 10 Jan 2014, 11:01 AM
Here i am attaching the code and php file .........i can read the data from the data base .but  cant update and delete...
after deletion value still in the database.. please help me..

<html>
<head>
<title>GRID PHP</title>
<link rel="stylesheet" href="CSS/kendo.common.min.css" />
<link rel="stylesheet" href="CSS/kendo.blueopal.min.css" />
<script type="text/javascript" src="JS/jquery.min.js"></script>
<script type="text/javascript" src="JS/kendo.all.min.js"></script>
<script type="text/javascript">
$(function() {
   $("#grid").kendoGrid({
                        dataSource: {
                            transport: {
                                read:{
url: "data/Fetch.php",
                dataType : "json",
//type: "GET"
},
update: {
                url: "data/Update.php",
                type: "POST"
            },
destroy: {
                url: "data/Delete.php",
                type: "DEETE"
            },
create: {
                url: "data/product.php",
                type: "PUT"
            },
error: function(e)
{
            alert(e.responseText);
        },

                                           
                            },
                                       //batch: true,
                            schema: {
data: "data",
                                model: {
                                                 id: "pid",
                                    fields: {
                                        pid: { editable: false },
                                        name: { type: "string",validation: { required: true}},
                                        price: { type: "number",validation: { required: true} },
description: {type: "string"},
                                    }
                                }
                            },
                            pageSize: 10
                        },
                         editable:  "popup",
                        height: 400,
selectable : "row",
                        //filterable: true,
                        //sortable: true,
                        pageable: true,
                        toolbar: ["create","save"],
                        columns: [
{
                                field:"pid",
                                title: "PID",
width:"50"
                                //filterable: true
                            },
{
field: "name",
title: "Name",
attributes: {style: "text-align: center; font-size: 14px;"},
},
{
field: "price",
title: "Price",
width:250
},

title: "Description",
field: "description" 
},
                                      
{ command: [{text:"Edit", name:"edit"}, 
{text:"Delete",name: "destroy"}], title: " ",width:200 }
                        ]
                    });
function detailInit(e) {
// get a reference to the current row being initialized
//var detailRow = e.detailRow;

// create the datasource
}
}); 

</script>
</head>
<body>
<div id="grid"></div>
</body>
</html>    

4 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 14 Jan 2014, 09:24 AM
Hello Thoams,

Do you receive that ID parameters on the server side successfully?

$rs = mysql_query($con,"DELETE FROM products  WHERE pid = " .$Id);

If you do then removing the item from the database should not be also done without any struggling.

Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Thomas
Top achievements
Rank 1
answered on 15 Jan 2014, 05:21 AM

Thank you  Petur Subev  I got it....
0
Thomas
Top achievements
Rank 1
answered on 17 Jan 2014, 08:14 AM


Hai all

I have another problem ...

I am using Popup editing ....When a user edits an existing record and saves the results, the data will update properly, but the PopUp window will not close
and also i want to refresh the grid after update and  create.........help me ....thank u......
0
Petur Subev
Telerik team
answered on 20 Jan 2014, 07:28 AM
Hello Thomas,

Are there any JavaScript errors in the console? If they are not, what exactly do you return from the server for that Update request? Do you return the updated record like shown here.

http://docs.kendoui.com/getting-started/using-kendo-with/php/widgets/grid/editing#create-php-file-which-performs-crud-(using-datasourceresult)

If you want to refresh the whole Grid with data from the server (not just the updated record because it will be refreshed automatically) then you should invoke the read() method of the dataSource when the requestEnd event is triggered.

e.g.

function onRequestEnd(e) {
     this.read();
}


Kind Regards,
Petur Subev
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
Thomas
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or