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

Sending data to grid

1 Answer 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Benedict
Top achievements
Rank 1
Benedict asked on 07 Aug 2013, 02:39 PM
 i have a form with a button that upon clicked should fill a grid with data via ajax to a php script. the php script is ok but no data is shown on the grid..here 's my code below...any help please!!!

//function for button clicked
      $(function(){
          $("#fetchmani").click(function(){
            var routes    = document.getElementById('routes').value;
                  $.ajax({
                        type: 'POST',
                        url: 'data/fetchmani.php',
                        data: "routes="+ routes,
                        success: function(response){
                           var grid = $("#grid").data("kendoGrid");
                           grid.dataSource.read();
                        }
                      });
        });
      });
              </script>
            <button id="fetchmani" class="k-button" style="margin-left:15px;width:100px">Fetch Manifest</button>


// grid code
var routeid = 0;
                $(document).ready(function () {
                      dataSource = new kendo.data.DataSource({
                            transport: {
                                read:  {
                                    url: "data/fetchmani.php",
                                    dataType: "json",
                                    type:"POST"
                                },
                                parameterMap: function(options, operation) {
                                  return {
                                      id: routeid
                                  }
                              }
                            },
                            batch: true,
                            pageSize: 20,
                            serverPaging: true,
                            serverSorting: true,
                            serverFiltering: true,
                            schema: {
                            data:"data",
                            total:"total"
                            }
                        });

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 09 Aug 2013, 01:38 PM
Hello,

 Your code looks correct and should have worked. Do you see any JavaScript errors when the button is clicked? Is the request to fetchmani.php made at all? You can check this in your browser's developer tools.

Regards,
Atanas Korchev
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
Benedict
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or