0

Can anyone assist in getting my Grid working so that it pulls and displays 50 rows at a time? It currently displays 50 rows but does not show any page numbering. I have included a total of 120 in the datasource but do not know where to go from here. How do I display the page numbers and pass $start, $limit variables to my query is is getting the data?

Where it should say "1 - 50 of 120 items" it says "No items to display"

Im stuck. :0(

var mydata =  {"data":[

        <?php foreach ($data_arr as $data){ ?>
            { "id": "<?php echo $data['id']; ?>",  "name":"<?php echo $data['surname'] . ', ' . $data['firstname']; ?>",  "company": "<?php echo $data['company']; ?>",   "Email": "<?php echo $data['email']; ?>"},
        <?php 
        }
        ?>
        ]       , "total": <?=$total?>};
>       
>       
>         $("#grid").kendoGrid({
>             dataSource: {
>                 data: mydata.data,
>                 schema: {
>                   total: "total",
>                     model: {
>                         fields: {
>                             id: { type: "number" },
>                             name: { type: "string" },
>                             company: { type: "string" },
>                             email: { type: "email" }
>                         }
>                     }
>                 },
>                 pageSize: 50
>             },            serverPaging: true,
>             scrollable: false,
>             sortable: true,
>             filterable: true,             selectable: "row",
>           detailTemplate: kendo.template($("#detailTemplate").html()),
>             detailInit: detailInit,
>             pageable: {refresh: true,},           
>             columns: [
>                 {field:"id",title: "ID",filterable: false},
>                 {field: "name",title: "Name"}, 
>                 {field: "company",title: "Company"}, 
>                 {field: "email",title: "Email"}             
>             ]                 
>         });

Then there's the server side PHP which does not seem to be getting anything from the URL all :

//get current page from URL
$get = $_SERVER['REQUEST_URI']; parse_str($get);
if(isset($page)){ $start = $page;

$limit = $pagesize;
} $admin = new Admin();

$count_data = $admin->countRows(); //brings back 120
$mydata= $admin->getRows($start=0,$limit=50);

4

2 回答 2

0

试试这个从 url 获取变量:

$start = $_GET['page'];
$limit = $_GET['pagesize'];

那应该工作

于 2013-08-23T13:34:39.913 回答
0

The grid's data source isn't configured for server binding. You must configure the transport.read option to provide the url which will return the paged data. The data source will post the page and pagesize.

Here is an online demo you can check: http://demos.kendoui.com/web/grid/remote-data.html

于 2013-08-24T02:39:58.263 回答