Results 1 to 2 of 2

Thread: want to fetch data for my combo in formpanel

  1. #1

    Default want to fetch data for my combo in formpanel

    hiiiiiiiiiiiiii


    i have one combo in my formpanel

    {
    xtype: 'combo',
    name: 'genre',
    fieldLabel: 'Genre',
    mode: 'local',
    store: genres,
    displayField:'genre',
    width: 120
    },


    and for fetching data in i have following code..

    var genres = new Ext.data.Store({
    reader: new Ext.data.JsonReader({
    fields: ['companyID', 'company'],
    root: 'rows'
    }),
    proxy: new Ext.data.HttpProxy({
    url: 'categories.php'
    }),
    autoLoad: true
    });

    and in categories.php...


    <?php
    //database parameters
    $user='root'; //user
    $pw='bij123'; //user password
    $db='test'; //name of database
    $table='stock'; //name of table data stored in

    $taxRate = 0.06;

    //make database connection
    $connection = mysql_connect("localhost", $user, $pw) or
    die("Could not connect: " . mysql_error());
    mysql_select_db($db) or die("Could not select database");

    // connection to database goes here
    $result = mysql_query('SELECT companyID,company FROM stock');
    If (mysql_num_rows($result) > 0) {
    while ($obj = mysql_fetch_object($result)) {
    $arr[] = $obj;
    }
    }
    echo '{rows:'.json_encode($arr).'}';
    ?>


    m having following code..
    please help me how to get data from db to show in combo..

    thanks

    rahul

  2. #2
    Sencha User fay's Avatar
    Join Date
    Apr 2007
    Location
    Ireland
    Posts
    1,750

    Default

    Your combo's displayField doesn't match any of the fields in your store. Try:

    Code:
     
    // ...
    displayField: 'company',
    valueField: 'companyID',
    // ...
    Also see: http://www.extjs.com/learn/Ext_FAQ_ComboBox

Posting Permissions

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