Paging Help

January 5th, 2009
  • Sorry to bug the forum so many times in one week but I have a small problem with a paging grid, this is my first time doing such a grid and I think I am very close.

    The grid loads with the first 25 items however when I try and page the load box appears then disappears but with no change to the grid,

    I am suer I am missing a step,

    Store

    var ds = new Ext.data.Store({
    url: './ajax-layers.php',
    baseParams:{
    start:0,
    limit:25
    },
    reader: new Ext.data.JsonReader({
    root: 'data',
    totalProperty: 'totalCount'
    },
    [{name:'gid', type:'float'}, 'name','approved','table']
    )

    });

    ds.load({params:{table:'atsi', start:0, limit:25}});
    ds.setDefaultSort('name', 'ASC');
    Grid


    var colModel = new Ext.grid.ColumnModel([
    {id:'id', dataIndex:'gid', header:'gid', width: 20, sortable: true},
    {dataIndex:'name', header:'Name', width: 150, sortable: true},
    {dataIndex:'approved', header:'Approved', width: 40, sortable: true, renderer: approvedColor},
    {dataIndex:'table', header:'Type', width: 60, sortable: true},
    {dataIndex:'gid', header:' ', width: 10, renderer: editIcon},
    {dataIndex:'gid', header:'', width: 10, renderer: profileIcon},
    {dataIndex:'gid', header:'', width: 10, renderer: uploadIcon},
    {dataIndex:'approved', header:' ', width: 10, renderer: approveIcon},
    {dataIndex:'approved', header:' ', width: 10, renderer: deleteIcon}
    ]);


    // create the Grid
    grid = new Ext.grid.GridPanel({
    ds: ds,
    cm: colModel,
    loadMask: true,
    title:'Layers',

    bbar: new Ext.PagingToolbar({
    pageSize: 25,
    store: ds,
    displayInfo: true,
    displayMsg: 'Displaying topics {0} - {1} of {2}',
    emptyMsg: "No topics to display"
    }),

    tbar : [
    new Ext.form.ComboBox({
    store: dropStore,
    valueField:'table',
    displayField:'name',
    hiddenName:'layerTable',
    fieldLabel:'Layer Type',
    name:'layerList',
    mode: 'local',
    triggerAction: 'all',
    emptyText:'Select Layer Type',
    selectOnFocus:true,
    width:500
    }),{
    xtype:'textfield',
    fieldLabel: 'search',
    name: 'search',
    width:315
    },{
    text : 'Go',
    tooltip : 'Change the layer type',
    handler : changeLayer
    }
    ],
    viewConfig: {
    forceFit: true
    }
    });ajax-layers.php


    ...

    $table = $_POST['table'];
    $start = $_POST['start'];
    $limit = $_POST['limit'];
    $search = $_POST['search'];

    if($search){
    $sql = "SELECT gid, name, approved FROM $table WHERE lower(name) LIKE lower('%$search%')";
    }else{
    $sql = "SELECT gid, name, approved FROM $table";
    }
    $rs = $db->Execute($sql);
    $recordCount = $rs->RecordCount();
    echo "{'totalCount':$recordCount,'data': [";

    if($search){
    $sql = "SELECT gid, name, approved FROM $table WHERE lower(name) LIKE lower('%$search%') LIMIT $limit OFFSET $start";
    }else{
    $sql = "SELECT gid, name, approved FROM $table LIMIT $limit OFFSET $start";
    }
    $rs = $db->Execute($sql);

    $i = 0;
    while (!$rs->EOF) {
    if($i != 0){echo ',';}
    $gid = $rs->fields['gid'];
    $name = $rs->fields['name'];
    $name = str_replace("'", "", $name);
    $name = str_replace("#", "", $name);
    $name = str_replace("-", " ", $name);

    $approved = $rs->fields['approved'];
    if($name != ""){
    echo "{'gid':'$start','name':'$name','approved':'$approv ed','table':'$table'}n";
    }
    $rs->MoveNext();
    $i++;
    }

    ?>
    ]}
    Do I need to add a handler to the page buttons? start doesn’t seem to be incrementing when I click on one of the page buttons.


  • The value of 'start' is not changing when one of the page buttons are being pressed. Do I need a handler on PagingToolbar that reloads the store with the new value of start?







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Paging Help , Please add it free.

    Posted in dballastages.com | edit