Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext User
    Join Date
    Jan 2011
    Posts
    4
    Vote Rating
    0
    Kanten is on a distinguished road

      0  

    Default Ext.data.Store reads 0 not int's from Ext.data.JsonReader (postgresql)

    Ext.data.Store reads 0 not int's from Ext.data.JsonReader (postgresql)


    I'm just starting so don't push me too hard

    Entrance -----------
    I'm trying to make on my machine (Win XP Home, PostgreSQL 8.2, Apache 2.2, ExtJs 3.3.1)
    tutorial http://www.sencha.com/learn/Tutorial:Grid_PHP_SQL_Part3

    Proper result You can see here http://w993.wrzuta.pl/obraz/powieksz/5utvI6Emhlu
    Numbers in columns '#' and 'IDparty'

    My problem You can see here http://w993.wrzuta.pl/obraz/powieksz/aPLT0biQgha
    The only change i made is in 'database.php'. Just use PostgreSQL not mySql
    PHP Code:
    function getList()
    {
        
    $pgs = new postgresql('localhost''login''pass''postgres');
        
    $result $pgs->sq"SELECT * "
            
    " FROM presidents pr, parties pa "
            
    "  WHERE pr.IDparty = pa.IDparty "
                          
    );
        
    $nbrows pg_num_rows($result);
        if(
    $nbrows>0){
            while(
    $rec pg_fetch_array($result)){
                            
    // render the right date format
                
    $rec['tookoffice']=codeDate($rec['tookoffice']);
                
    $rec['leftoffice']=codeDate($rec['leftoffice']);
                
    $arr[] = $rec;
            }
            
    $jsonresult JEncode($arr);
            echo 
    '({"total":"'.$nbrows.'","results":'.$jsonresult.'})';
        } else {
            echo 
    '({"total":"0", "results":""})';
        }

    Result is correct. Checked in Firebug.

    I'm using the same mainsript.js as tutorial's author

    Code:
    var PresidentsDataStore;
    var PresidentsColumnModel;
    var PresidentListingEditorGrid;
    var PresidentListingWindow;
    
    Ext.onReady(function(){
    
      Ext.QuickTips.init();
    
      PresidentsDataStore = new Ext.data.Store({
          id: 'PresidentsDataStore',
          proxy: new Ext.data.HttpProxy({
                    url: 'database.php', 
                    method: 'POST'
                }),
                baseParams:{task: "LISTING"}, // this parameter is passed for any HTTP request
          reader: new Ext.data.JsonReader({
            root: 'results',
            totalProperty: 'total',
            id: 'id'
          },[ 
            {name: 'IDpresident', type: 'int', mapping: 'IDpresident'},
            {name: 'FirstName', type: 'string', mapping: 'firstname'},
            {name: 'LastName', type: 'string', mapping: 'lastname'},
            {name: 'IDparty', type: 'int', mapping: 'IDparty'},
            {name: 'PartyName', type: 'string', mapping: 'name'},
            {name: 'TookOffice', type: 'date', mapping: 'tookoffice'},
            {name: 'LeftOffice', type: 'date', mapping: 'leftoffice'},
            {name: 'Income', type: 'float', mapping: 'income'}
          ]),
          sortInfo:{field: 'IDpresident', direction: "ASC"}
        });
        
      PresidentsColumnModel = new Ext.grid.ColumnModel(
        [{
            header: '#',
            readOnly: true,
            dataIndex: 'IDpresident',
            width: 50,
            hidden: false
          },{
            header: 'First Name',
            dataIndex: 'FirstName',
            width: 60,
            editor: new Ext.form.TextField({
                allowBlank: false,
                maxLength: 20,
                maskRe: /([a-zA-Z0-9\s]+)$/
              })
          },{
            header: 'Last Name',
            dataIndex: 'LastName',
            width: 80,
            editor: new Ext.form.TextField({
              allowBlank: false,
              maxLength: 20,
              maskRe: /([a-zA-Z0-9\s]+)$/
              })
          },{
            header: 'ID party',
            readOnly: true,
            dataIndex: 'IDparty',
            width: 50,
            hidden: true
          },{
            header: 'Party',
            dataIndex: 'PartyName',
            width: 150,
            readOnly: true
          },{
                    header: 'Took Office',
                    dataIndex: 'TookOffice',
                    width: 80,
                    renderer: Ext.util.Format.dateRenderer('m/d/Y'),
                    editor: new Ext.form.DateField({
                        format: 'm/d/Y'
                    }),
                    hidden: false
            },{
                    header: 'Left Office',
                    dataIndex: 'LeftOffice',
                    width: 80,
                    renderer: Ext.util.Format.dateRenderer('m/d/Y'),
                    editor: new Ext.form.DateField({
                        format: 'm/d/Y'
                    }),
                    hidden: false
            },{
            header: "Income",
            dataIndex: 'Income',
            width: 150,
            renderer: function(v){ return '$ ' + v; },
            editor: new Ext.form.NumberField({
              allowBlank: false,
              allowDecimals: true,
              allowNegative: false,
              blankText: '0',
              maxLength: 11
              })
          }]
        );
        PresidentsColumnModel.defaultSortable= true;
        
      PresidentListingEditorGrid =  new Ext.grid.EditorGridPanel({
          id: 'PresidentListingEditorGrid',
          store: PresidentsDataStore,
          cm: PresidentsColumnModel,
          enableColLock:false,
          clicksToEdit:1,
          selModel: new Ext.grid.RowSelectionModel({singleSelect:false})
        });
        
      PresidentListingWindow = new Ext.Window({
          id: 'PresidentListingWindow',
          title: 'The Presidents of the USA',
          closable:true,
          width:700,
          height:350,
          plain:true,
          layout: 'fit',
          items: PresidentListingEditorGrid
        });
      
      PresidentsDataStore.load();
      PresidentListingWindow.show();
    });


    Response from 'database.php' is have correct, there are numbers, not zeroes. Checked in Firebug.

    I use ext-all.css, ext-base.js, ext-all.js given by ExtJs 3.3.1
    Author used ExtJs 2.0.2 and gives his version of : ext-all.css, ext-base.js, ext-all.js (when i used that i had just blanks, not even zeroes)

    I tried all combinations:
    ExtJs 2.0.2 + 2.0.2 (ext-all.css, ext-base.js, ext-all.js) -> blanks
    ExtJs 2.0.2 + authors (ext-all.css, ext-base.js, ext-all.js) -> blanks
    ExtJs 3.3.1 + authors (ext-all.css, ext-base.js, ext-all.js) -> blanks
    ExtJs 3.3.1 + 3.3.1 (ext-all.css, ext-base.js, ext-all.js) -> zeroes

    Please help me. I want my int's

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    94
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    1. Are you sure those fields are integers? Try using type:'auto' for the fields (you don't care about their field types anyway).
    2. 'id' for both Store and JsonReader are deprecated. Use 'storeId' for Ext.data.Store and 'idProperty' for JsonReader.
    3. Your type:'date' fields should have dateFormat, so they don't rely on the browser date format which is dependent on the locale.

  3. #3
    Ext User
    Join Date
    Jan 2011
    Posts
    4
    Vote Rating
    0
    Kanten is on a distinguished road

      0  

    Default


    Thank You Condor for quick help.

    I just solved the problem. Big letters in columns mapping.

    {name: 'IDpresident', type: 'int', mapping: 'IDpresident'},
    {name: 'FirstName', type: 'string', mapping: 'firstname'},
    {name: 'LastName', type: 'string', mapping: 'lastname'},
    {name: 'IDparty', type: 'int', mapping: 'IDparty'},
    {name: 'PartyName', type: 'string', mapping: 'name'},
    {name: 'TookOffice', type: 'date', mapping: 'tookoffice'},
    {name: 'LeftOffice', type: 'date', mapping: 'leftoffice'},
    {name: 'Income', type: 'float', mapping: 'income'}

    they MUST be small, because in JsonReader result You have small
    ... {"0":"1","idpresident":"1","1":"1","idparty":"1","2":"George","firstname":"George","3":"Washington","lastname":"Washington","4":"1789-04-30","tookoffice":"04\/30\/1789","5":"1797-03-04","leftoffice":"03\/04\/1797","6":"135246.32","income":"135246.32","7":"1","8":"No Party","name":"No Party"} ...

    Well. First problem solved... i like ExtJs again

  4. #4
    Sencha User
    Join Date
    May 2014
    Posts
    4
    Vote Rating
    0
    davedran is on a distinguished road

      0  

    Default


    Hi!

    Appreciate if you can share your source code.

    I have not able to get Postgresql working with ExtJS

    Thank you.

    David

Similar Threads

  1. Problem with ComboBox, Ext.data.JsonReader and Ext.data.Store
    By Daniyar in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 12 Nov 2010, 1:56 AM
  2. Ext.data.JsonReader & Ext.data.Record
    By seek in forum Ext 3.x: Help & Discussion
    Replies: 6
    Last Post: 4 Aug 2010, 5:56 AM
  3. Is Ext.Data.JSONReader invoked when add method is called on Ext.Data.Store
    By nagavasantha in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 9 Sep 2009, 7:34 AM
  4. jsonreader not working for me in a Ext.data.Store
    By jonesmc123 in forum Ext 2.x: Help & Discussion
    Replies: 8
    Last Post: 6 Dec 2007, 7:14 PM

Thread Participants: 2