Results 1 to 3 of 3

Thread: Populate grid via Json

  1. #1
    Ext JS Premium Member
    Join Date
    Dec 2007
    Posts
    213

    Default Populate grid via Json

    Hi,

    I have created a sample to populate a grid via Json - The grid shows up with the data and I can see the previous/forward symbols but the is the same even if I move to the next page or try to sort - any help please?

    PHP Code:
    Ext.onReady(function(){

        
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

        
    // create the data store
        
    var ds = new Ext.data.JsonStore({
            
    url:'ajaxtest.asp',
            
    totalProperty'total',
            
    root'data',
            
    fields: [
                {
    name'fieldid'},
                {
    name'allocationname'},
                {
    name'invoicenumber'},
                {
    name'supportnumber'},
                {
    name'serialnumber'}
            ],
            
    remoteSorttrue
        
    });

        
        
    // create the Grid
        
    var grid = new Ext.grid.GridPanel({
            
    dsds,
            
    columns: [
                {
    id:'fieldid',header"ID"width160sortabletruedataIndex'fieldid'},
                {
    header"Name"width75sortabletruedataIndex'allocationname'},
                {
    header"Invoice"width75sortabletruedataIndex'invoicenumber'},
                {
    header"Support Number"width85sortabletruedataIndex'supportnumber'},
                {
    header"Serial"width75sortabletruedataIndex'serialnumber'}
            ],
            
    stripeRowstrue,
            
    loadMasktrue,
            
    height:350,
            
    width:770,

            
    tbar: new Ext.PagingToolbar({
                
    pageSize15,
                
    storeds,
                
    displayInfotrue,
                
    displayMsg'Displaying results {0} - {1} of {2}',
                
    emptyMsg"No Records Found!"
            
    })
            
        });

        
    grid.render('grid-example');
        

        
    grid.getSelectionModel().selectFirstRow();
        
    ds.load({params:{start0limit15}});
    }); 
    data file
    PHP Code:
    {total:"30",data:[                                                                                        
    {
    fieldid:"1",allocationname:"username1",invoicenumber:"10001",supportnumber:"20001",serialnumber:"30001"},
    {
    fieldid:"2",allocationname:"username2",invoicenumber:"10002",supportnumber:"20002",serialnumber:"30002"},
    {
    fieldid:"3",allocationname:"username3",invoicenumber:"10003",supportnumber:"20003",serialnumber:"30003"},
    {
    fieldid:"4",allocationname:"username4",invoicenumber:"10004",supportnumber:"20004",serialnumber:"30004"},
    {
    fieldid:"5",allocationname:"username5",invoicenumber:"10005",supportnumber:"20005",serialnumber:"30005"},
    {
    fieldid:"6",allocationname:"username6",invoicenumber:"10006",supportnumber:"20006",serialnumber:"30006"},
    {
    fieldid:"7",allocationname:"username7",invoicenumber:"10007",supportnumber:"20007",serialnumber:"30007"},
    {
    fieldid:"8",allocationname:"username8",invoicenumber:"10008",supportnumber:"20008",serialnumber:"30008"},
    {
    fieldid:"9",allocationname:"username9",invoicenumber:"10009",supportnumber:"20009",serialnumber:"30009"},
    {
    fieldid:"10",allocationname:"username10",invoicenumber:"10010",supportnumber:"20010",serialnumber:"30010"},
    {
    fieldid:"11",allocationname:"username11",invoicenumber:"10011",supportnumber:"20011",serialnumber:"30011"},
    {
    fieldid:"12",allocationname:"username12",invoicenumber:"10012",supportnumber:"20012",serialnumber:"30012"},
    {
    fieldid:"13",allocationname:"username13",invoicenumber:"10013",supportnumber:"20013",serialnumber:"30013"},
    {
    fieldid:"14",allocationname:"username14",invoicenumber:"10014",supportnumber:"20014",serialnumber:"30014"},
    {
    fieldid:"15",allocationname:"username15",invoicenumber:"10015",supportnumber:"20015",serialnumber:"30015"},
    {
    fieldid:"16",allocationname:"username16",invoicenumber:"10016",supportnumber:"20016",serialnumber:"30016"},
    {
    fieldid:"17",allocationname:"username17",invoicenumber:"10017",supportnumber:"20017",serialnumber:"30017"},
    {
    fieldid:"18",allocationname:"username18",invoicenumber:"10018",supportnumber:"20018",serialnumber:"30018"},
    {
    fieldid:"19",allocationname:"username19",invoicenumber:"10019",supportnumber:"20019",serialnumber:"30019"},
    {
    fieldid:"20",allocationname:"username20",invoicenumber:"10020",supportnumber:"20020",serialnumber:"30020"},
    {
    fieldid:"21",allocationname:"username21",invoicenumber:"10021",supportnumber:"20021",serialnumber:"30021"},
    {
    fieldid:"22",allocationname:"username22",invoicenumber:"10022",supportnumber:"20022",serialnumber:"30022"},
    {
    fieldid:"23",allocationname:"username23",invoicenumber:"10023",supportnumber:"20023",serialnumber:"30023"},
    {
    fieldid:"24",allocationname:"username24",invoicenumber:"10024",supportnumber:"20024",serialnumber:"30024"},
    {
    fieldid:"25",allocationname:"username25",invoicenumber:"10025",supportnumber:"20025",serialnumber:"30025"},
    {
    fieldid:"26",allocationname:"username26",invoicenumber:"10026",supportnumber:"20026",serialnumber:"30026"},
    {
    fieldid:"27",allocationname:"username27",invoicenumber:"10027",supportnumber:"20027",serialnumber:"30027"},
    {
    fieldid:"28",allocationname:"username28",invoicenumber:"10028",supportnumber:"20028",serialnumber:"30028"},
    {
    fieldid:"29",allocationname:"username29",invoicenumber:"10029",supportnumber:"20029",serialnumber:"30029"},
    {
    fieldid:"30",allocationname:"username30",invoicenumber:"10030",supportnumber:"20030",serialnumber:"30030"}]} 

  2. #2
    Ext User halkon_polako's Avatar
    Join Date
    Nov 2007
    Location
    Barcelona
    Posts
    193

    Default

    You are returning 30 rows instead of 15. Your backend code must return the correct rows using start and limit parameters.

  3. #3
    Ext JS Premium Member
    Join Date
    Dec 2007
    Posts
    213

    Default

    Opps! I just created a text file for testing and forgot!

    Thanks!

    Quote Originally Posted by halkon_polako View Post
    You are returning 30 rows instead of 15. Your backend code must return the correct rows using start and limit parameters.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •