Results 1 to 9 of 9

Thread: My Data from table didn't show

  1. #1

    Exclamation My Data from table didn't show

    dear friends, i'm using extjs grid to show my table from database but it didn't show up.
    I'm using postgreSQL. I'm wonder what's wrong with my code.

    here ext code
    Code:
    Ext.onReady(function(){
        Ext.QuickTips.init();
            
        var SimpleDataStore = new Ext.data.JsonStore({
            root: 'results',
            totalProperty: 'total',
            url: 'wo.php',
            /*proxy: new Ext.data.HttpProxy({
                url: 'wo.php',
                method: 'POST'
            }),*/
            fields: 
            [{name: 'nom', type: 'int'},
             {name: 'wono', type: 'string'},
             {name: 'title', type: 'string'},
             {name: 'br_descr', type: 'string'},
             {name: 'wotype', type: 'int'},
             {name: 'attach', type: 'string'},
             {name: 'issuedt2', type: 'string'},
             {name: 'issuedby', type: 'string'},
             {name: 'dept', type: 'string'},
             {name: 'priority', type: 'string'},
             {name: 'duedt', type: 'date'},
             {name: 'clid', type: 'string'},
             {name: 'prodid', type: 'string'},
             {name: 'moduleid', type: 'string'},
             {name: 'projid', type: 'string'},
             {name: 'csissue', type: 'string'},
             {name: 'chgreg', type: 'string'},
             {name: 'resolution', type: 'string'},
             {name: 'wogroup', type: 'string'},
             {name: 'complex', type: 'string'},
             {name: 'impact', type: 'string'},
             {name: 'estday', type: 'string'},
             {name: 'estfinish', type: 'string'},
             {name: 'assgn', type: 'string'},
             {name: 'keyword1', type: 'string'},
             {name: 'keyword2', type: 'string'},
             {name: 'refwono', type: 'string'},
             {name: 'rftdt', type: 'string'},
             {name: 'dbch', type: 'string'},
             {name: 'status', type: 'string'},
             {name: 'tester', type: 'string'},
             {name: 'projstat', type: 'string'},
             {name: 'recdt', type: 'string'},
             {name: 'wkprtsts', type: 'string'},
             {name: 'issuedt', type: 'string'},
             {name: 'csrno', type: 'string'},
             {name: 'sos', type: 'string'},
             {name: 'groupflag', type: 'string'},
             {name: 'regby', type: 'string'},
             {name: 'regdt', type: 'string'},
             {name: 'tester', type: 'string'}
            ],
            sortInfo: {field: 'wono', directions: "DESC"}
        });
        
        
        var SimpleColumnModel = new Ext.grid.ColumnModel([
            { header: 'Wo Number',
              dataIndex: 'wono',
              width: 250
            },{
              header: 'Title',
              dataIndex: 'title',
              width: 250
            },{
              header: 'Product ID',
              dataIndex: 'prodid',
              id: 'prod',
              renderer: function(prod){
                    return '<pre >' + prod + '</pre>';
              },
              width: 80
            },{
              header: 'Module ID',
              dataIndex: 'moduleid',
              width: 80
            },{
              header: 'Issued By',
              dataIndex: 'issuedby',
              width: 100
            },{
              header: 'Issued Date',
              dataIndex: 'issuedt',
              width: 100
            },{
              header: 'Reg By',
              dataIndex: 'regby',
              width: 100
            },{
              header: 'Reg Date',
              dataIndex: 'regdt',
              width: 100
            },{
              header: 'Tester 1',
              dataIndex: 'tester',
              width: 100
            },{
              header: 'Tester 2',
              dataIndex: 'tester2',
              width: 100
            },{
              header: 'Exp. 1<sup>st</sup> RFT Date',
              dataIndex: 'duedt',
              width: 100
            },{
              header: 'Due date',
              dataIndex: 'rftdt',
              width: 100
            },{
              header: 'CS Issue',
              dataIndex: 'csissue',
              width: 100
            },{
              header: 'Assign To',
              dataIndex: 'assgn',
              width: 70
            },{
              header: 'Status',
              dataIndex: 'status',
              width: 70
            },{
              header: 'CLS date',
              dataIndex: '',
              width: 100
            },{
              header: 'SOS',
              dataIndex: 'sos',
              width: 70
            },{
              header: 'FIX',
              dataIndex: '',
              width: 70
            },{
              header: 'CRQ',
              dataIndex: '',
              width: 70
            }
        ]);
        SimpleColumnModel.defaultSortable= true;
                
            
        var SimpleListingEditorGrid =  new Ext.grid.GridPanel({
            title: 'Work Order',
            store: SimpleDataStore,
            cm: SimpleColumnModel,
            viewConfig: {
                forceFit: true
            },
            frame: true,
            stripeRows: true,
            collapsible: true,
            animCollapse: true,
            autoWidth: true,
            autoHeight: true,
    
            bbar: new Ext.PagingToolbar({ //paging grid
                pageSize: 20,
                store: SimpleDataStore,
                displayInfo: true,
                displayMsg: 'Displaying data {0} - {1} of {2}',
                emptyMsg: "No data to display"
            })
        });
        SimpleDataStore.load({params:{start:0,limit:20}});
        var myPanel = new Ext.Panel({
            autoScroll: true,
            renderTo: 'wo',
            items: [ SimpleListingEditorGrid ]
        });
        
    });
    and here is the php code
    Code:
    <?
    include "JSON.php";
    //include "koneksi.php";
    
    $conn = pg_connect("host='localhost' port=5432 dbname='waroeng' user='waroeng' password='waroengadm'");
    if (!$conn) {
          die("Error in connection: " . pg_last_error()); 
    }
    
    $query = "select wono from wo order by nom desc";
    $hasil = pg_query($conn, $query);
    $nbrows = pg_num_rows($hasil);
    $start = (integer) (isset($_POST['start']) ? $_POST['start'] : $_GET['start']);
    $end = (integer) (isset($_POST['limit']) ? $_POST['limit'] : $_GET['limit']);
    $limit = $query." limit ".$start.",".$end;
    $result = pg_query($conn, $limit);
    
    $arr = array();
    if($nbrows>0)
    {
        while($rec = pg_fetch_array($result)){ 
            $arr[] = $rec;
        }
        $jsonresult = JEncode($arr);
        echo '({"total":"'.$nbrows.'","results":'.$jsonresult.'})';
    } else {
        echo '({"total":"0", "results":""})';
    }
    
    function JEncode($arr){
    if (version_compare(PHP_VERSION,"5.2","<"))
    {
        require_once("JSON.php");
        $json = new Services_JSON();
        $data=$json->encode($arr);
    } else {
            $data = json_encode($arr);
    }
    return $data;
    }
    }
    
    ?>

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Debug.

    1. Does the server return the expected JSON data (use Firebug Net tab or Fiddler)?
    2. Does the store fire an exception event?
    3. Does the store fire a load event?

  3. #3

    Default

    No, it's just return blank/nothing even in firebug

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    So this is a PHP problem? This might not be the best forum to ask PHP questions...

  5. #5

    Default

    it's a php problem?? is my json right?

  6. #6
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Have you looked at the JSON?

  7. #7

    Default

    dear friends, if i change mysql statement to "select * from wo" return :

    ({"total":"7745","results":null})

  8. #8
    Sencha User
    Join Date
    Jun 2007
    Posts
    266

    Default

    the results: null is telling you there is NO records coming back. it should look similar to

    {"total":"7745","results":{yourDataIndexName:dataValue.....}}

    Your PHP is not returning anything, which is where your problem lies, not in extjs

  9. #9
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    The root must be an Array:

    Code:
    {"total":"7745","results":[{yourDataIndexName:dataValue.....}]}

Posting Permissions

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