2011-12-19 20 views
0

私は次のようなJSON構造を持つjqgrid - ページネーション

JSON

{ 
    "page":"1", 
    "total":"3", 
    "records":"15", 
    "mypage":{ 
     "outerwrapper":{ 
     "innerwrapper":{ 
      "rows":[ 
       { 
        "id":"1", 
        "read": true, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          }, 
          { 
           "name":"link3" 
          } 
         ] 
        } 
        ] 
       }, 
       { 
        "id":"2", 
        "read": false, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          } 
         ] 
        } 
        ] 
       }, 
       { 
        "id":"3", 
        "read": false, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          } 
         ] 
        } 
        ] 
       }, 
       { 
        "id":"4", 
        "read": false, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          } 
         ] 
        } 
        ] 
       }, 
       { 
        "id":"5", 
        "read": false, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          } 
         ] 
        } 
        ] 
       }, 
       { 
        "id":"6", 
        "read": false, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          } 
         ] 
        } 
        ] 
       }, 
       { 
        "id":"7", 
        "read": false, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          } 
         ] 
        } 
        ] 
       }, 
       { 
        "id":"8", 
        "read": false, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          } 
         ] 
        } 
        ] 
       }, 
       { 
        "id":"9", 
        "read": false, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          } 
         ] 
        } 
        ] 
       }, 
       { 
        "id":"10", 
        "read": false, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          } 
         ] 
        } 
        ] 
       }, 
       { 
        "id":"11", 
        "read": false, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          } 
         ] 
        } 
        ] 
       }, 
       { 
        "id":"12", 
        "read": false, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          } 
         ] 
        } 
        ] 
       }, 
       { 
        "id":"13", 
        "read": false, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          } 
         ] 
        } 
        ] 
       }, 
       { 
        "id":"14", 
        "read": false, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          } 
         ] 
        } 
        ] 
       }, 
       { 
        "id":"15", 
        "read": true, 
        "cells": [ 
        { 
         "label":"linkimg", 
         "links": [ 
          { 
           "name":"link1" 
          }, 
          { 
           "name":"link2" 
          } 
         ] 
        } 
        ] 
       } 
      ] 
     } 
     } 
    } 
} 

ご注意:をページネーションのためのpagetotalrecordsmypageを定義されていること。これは機能します。私はPage 1 of 3, 2 of 3 and 3 of 3を得る。私は、outerwrapper後に改ページためpagetotalrecordsを置く場合は

それは動作しません。は、私はあなたのJSON入力データの内pagetotalrecordsの場所を変更したい場合は、新しい場所についてjqGridに通知する必要がありPage 0 of 3

{ 
    "mypage":{ 
     "outerwrapper":{ 
     "page":"1", 
     "total":"3", 
     "records":"15", 
     .... 
     .... 
     } 
    } 
} 

答えて

1

を取得します。これはjsonReaderを使用して行うことができます。たとえば、あなたはjqGrid

jsonReader: { 
    page: 'mypage.outerwrapper.page', 
    total: 'mypage.outerwrapper.total', 
    records: 'mypage.outerwrapper.records' 
} 
+0

のパラメータのリストに次のjsonReaderを追加することができますが、この1で私を助けてくださいことはできますか?私はこれに固執しています。 http://stackoverflow.com/questions/8618691/jqgrid-how-to-map-cell-data-to-column-model-if-column-model-is-in-json-respons – techlead

関連する問題