1
votes

Using ExtJs, I m testing to transfer received xml data to specific grid. I made a simple text file which has 10 output values , and set pageSize to 5 from paging toolbar.

That is, the desired output for 10 values could be 5 values on each pages(2 pages). It divided to 2 pages correctly, however there are 10 same values on each pages.

What is the cause for above problem? I hope your comments will be possible solutions. Thank you!

index.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<link rel="stylesheet" type="text/css" href="resources/css/ext-all.css" />
<script src="resources/js/ext-base.js"></script>
<script src="resources/js/ext-all-debug.js"></script>
<script src="resources/ux/BufferView.js"></script>
<script type="text/javascript">

    Ext.onReady(function(){ 
         var mm = Ext.data.Record.create([  
          {name: 'mb_id'},
          {name: 'mb_sex'},
          {name: 'mb_name'}
         ]);


         var store = new Ext.data.Store({
          proxy: new Ext.data.HttpProxy({
           method:'GET',
           url:'./grid2.php'
          }),  

          reader: new Ext.data.XmlReader(
                {
                    record: 'Item'  
                    },  [
                            'mb_id'
                            ,'mb_sex'
                            ,'mb_name'
                         ]  
                    ),
                    autoLoad: {params:{start: 0, limit: 5}}

         });


         var grid = new Ext.grid.GridPanel({ 
            renderTo: document.body, 
            frame:true, 
            title: 'information', 
            height:300, 
            width:516, 
            store: store, 
            columns: [ 
                {header: "id", dataIndex: 'mb_id'},//, renderer: cover_image
                {header: "sex", dataIndex: 'mb_sex',width:100},
                {header: "name", dataIndex: 'mb_name',width:100}
            ],
            bbar:new Ext.PagingToolbar({
            store:store,
            pageSize:5,
            displayInfo:true
            })
        }); 
    }); 


</script>
</HEAD>
<BODY>
</BODY>
</HTML>

data.php

    header("Content-type: application/xml");    //;charset=utf-8
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";

    echo "<root>";

    //전체 데이터 레코드 값 기록
    for($i=0;$i<10;$i++)
    {

            echo "<Record>";
            echo "<Time>".$i."</Time>";
            echo "<Name>".$i."</Name>";
            echo "</Record>";
    }
    echo "</root>";
1
paging is controlled in the store and the toolbar. It is not a config in the grid object. - Tim

1 Answers

0
votes

As Tim suggested, remove the pageSize parameter from your paging toolbar and instead add it to your store:

var store = new Ext.data.Store({
    pagesize: 5,
    proxy: new Ext.data.HttpProxy({
        method:'GET',
        url:'./grid2.php'
    })
}) ...