简体   繁体   中英

KendoUI Grid server pagination using php

I want the server side paging in kendo ui using php.So anybody know how to do that? I have do like serverpaging=true in grid.And for server side logic i need the which page number is selected so i can calculate like pagenumber*perpage and get that records by query. But how to pass that selected page number to server side?

var crudServiceBaseUrl = "<?=base_url()?>",
                 dataSource = new kendo.data.DataSource({
                   transport: {
                    read:  {
                        url: crudServiceBaseUrl+"did_grid_list",
                        type:"GET",
                        dataType: "jsonp"
                    },
 serverPaging: true,
 pageSize: 20,
                schema: {
                    total: function(data) { console.log(10034); return 10034; },
                    model: {
                          id: "id",     
                        fields: {
                            did: { validation: { required: true,max:9 } },
                                }
                               }
                             }
                         });

above code is my view file.COntroller side is like

$json_data = array();
            $count_all = count($this->dids_model->did_get($action));    
        $page_no = $_GET['page']; 

        $json_data['page'] = $page_no;          
        $json_data['total'] = ($count_all>0) ? $count_all : 0;

         $perpage = 20;
         $start = ($page_no-1) * $perpage;
         if($start < 0 )
         $start = 0;
                $result = $this->dids_model->did_get($action,$start,$perpage);

Please, take a look into serverPaging documentation. It shows you the parameters that you will receive in your request referring to:

  1. take : contains the number of records to retreive
  2. skip : how many records from the front of the dataset to begin reading
  3. page : the index of the current page of data
  4. pageSize : the number of records per page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM