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

Can't delete grid row and show total records

0 Answers 141 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Quang
Top achievements
Rank 1
Quang asked on 21 May 2012, 04:14 PM
When I delete grid row I want it  disappear on web page but when I press F5 to refersh not any row is deleted, furthermore I can't find any tutorial show total of records at the footer, how can I did ? the function update is ok.

Here is my code:

  <script>
                $(function(){
                    $("#grid").kendoGrid({
                    scrollable: true,
                    pageable: true,   
                    sortable:true,
                    filterable: true,
                    dataSource:
                                {
                                        transport:
                                                    {
                                                        read:"../data/all_products.php"
                                                        ,update:{url:"../data/update.php",type:"POST"}
                                                        ,destroy: {url:"../data/delete.php",type:"POST"}
                                                    }//pageSize:5,serverPaging: true,
                    ,schema:
                        {
                            data:"data"
                            ,total:function(result)
                               
                            {
                                var data=this.data(result);
                                return data ? data.length:0;
                            }
                            
                        , model:
                            {
                                id:"id",
                                fields:
                                   
                                {
                                    name:{editable:true}
                                    ,price:{type:"number",editable:true}
                                    ,thumbnail:{editable:false}
                                }
                             }
                        }
                    ,  pageSize:5
                    }    
                    ,columns:[
                                {field:"name"}
                                ,{field:"product_name",title:"product name"}
                                ,{field:"price", format:"{0:c0}"}
                                ,{field:"thumbnail",template:"<img src='#= thumbnail #' /> "}
                                ,{command:"destroy",title:"&nbsp;",width:110}
                                ]
                    ,navigatable: true                
                    ,editable: true   
                    ,toolbar:["save","cancel"]});
                });
            </script>

and here is my delete.php


<?php
   
   include ('../data/products.php');
   $db=new Database()  ;
 
 $verb = $_SERVER["REQUEST_METHOD"];
   
  if ($verb == "POST")
  {
      $product_id= mysql_real_escape_string($_POST['id']); 
       
      $sql="delete from tbl_products where id='".$product_id."' ";
      $rs=$db->Query($sql) ;
 
      echo json_encode($rs);
  }
?>

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Quang
Top achievements
Rank 1
Share this question
or