2014-02-24 2 views
0

여기 내 스레드입니다.이 섹션에서는 페이징의 실제 문제를 게시했습니다. 이 스레드 엽차 포럼 sencha forum Ext Paging problem with EXt direct Grid panelExt Js 페이징이 ExtDirect 그리드 패널에서 작동하지 않습니다.

First pageSecond page

+0

페이지 매김을 처리 할 서버 측 코드가 있습니까? 다음을 클릭하면 시작 및 제한 매개 변수가있는 그리드 저장소가 호출되므로 해당 값을 사용하여 서버에서 결과를 반환해야합니다. – objectone

+0

예 처음 시작할 때 한계가 생기고 적용 할 때 첫 번째로드에서 5 개의 값만 얻습니다. 다음 페이지가 사용 중지됨 –

+0

totalproperty, 즉 페이지 매김에 사용할 총 레코드 수를 가져와야합니다. 결과는 총 레코드 수 (예 : 47)이며 프록시 판독기 totalProperty에 매핑해야합니다. 예제가 필요하면 알려주십시오 – objectone

답변

0

에서 나를 도울 수 아래 상점 및 샘플 결과는 그래서 필요에 따라 사용자의 페이지 매김이 작동해야한다 방법에 대한 예제입니다.

스토어 내가 포럼에서 대답을 얻었다 마지막으로

{ 
    recordCount: 63, 
    records: [ 
    { 
    id: 944, 
    firstName: "Shannon", 
    lastName: "Joy" 
    }, 
    { 
    id: 1819, 
    firstName: "Remi" 
    lastName: "Lucas" 
    }, 
    ....... 
} 
1

처럼

var myStore = Ext.create('Ext.data.Store', { 
fields: [ 
    {name: 'firstName', type: 'string'}, 
    {name: 'lastName', type: 'string'} 
], 
proxy: { 
    type: 'ajax', 
    url: '/users.json', 
    reader: { 
     type: 'json', 
     root: 'records', 
     totalProperty: 'recordCount', 
     successProperty: 'success' 
    } 
} 
}); 

하고 서버에서 결과가 있어야한다 아래처럼 보일 것입니다

내 가게 JS

var store = Ext.create('Ext.data.Store', { 
     model : 'Users', 
     remoteSort : true, 
     autoLoad : true, 
     pageSize: 5, // items per page 

     sorters : [{ 
      property : 'name', 
      direction : 'ASC' 
     }], 

     proxy : { 
      type : 'direct', 
      directFn : 'Users.showAllUsers', 
      reader: { 

        root: 'users' 

      } 

     } 
}); 

내 PHP 함수

function showAllUsers($params) 
{ 
    $sort = $params->sort[0]; 
    $field = $sort->property; 
    $direction = $sort->direction; 
    $start = $params->start; 
    $end = $params->limit; 

    ($direction == 'ASC' ? 'ASC' : 'DESC'); 

    $dbh = Dbconfig::dbconnect(); 

    $stmt = $dbh->prepare("SELECT count(*) FROM users"); 
    $stmt->execute(); 
    $number_of_rows = $stmt->fetchColumn(); 

    $sth = $dbh->prepare("SELECT * FROM users ORDER BY name $direction LIMIT $start,$end"); 
    $sth->execute(); 
    $dataAll = $sth->fetchAll(); 


    $data = array(
      "success" => mysql_errno() == 0, 
      "total" => $number_of_rows, 
      "users" => $dataAll 
    ); 

    return $data; 
} 
관련 문제