1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    42
    Vote Rating
    1
    Answers
    2
    muceli is on a distinguished road

      0  

    Default Unanswered: GridPanel Store with PHP + MySql Table

    Unanswered: GridPanel Store with PHP + MySql Table


    Turning to the database records. However, do not store the object records.

    grid.png

    + app
    +view
    -Main.js
    +store
    -ListeStore.js
    model
    +data
    store.php // database connection and sql query
    +extjs // ext js library
    app.js
    index.php

    data/store.php

    PHP Code:
    <?php
    function getList() {   
     
    $connectmysql_connect("localhost""root","");    
     
    $db mysql_select_db("crud_extjs4"$connect) or die("error");
     
    $querymysql_query("select userID, name, lastname, age from users");    
     
    $i 0;    
     while(
    $resultmysql_fetch_assoc($query)) {        
         
    $data["liste"][$i] = $result;       
         
    $i++;  
     };    
     
    $json json_encode($data);    
     return 
    $json;
    }
    echo 
    getList();
    ?>
    app/view/Main.js

    Ext.define('PHPExtJS4.view.Main',{
    extend: 'Ext.grid.Panel',
    alias : 'widget.Liste',
    id:'myList',
    title: 'Liste',
    padding: '20',
    store: 'ListeStore',
    columns: [
    { id: 'userID', header: "Id", width: 50, sortable: true, dataIndex: 'userID' },
    { id:'name', header: "User Name", width: 75, sortable: true, dataIndex: 'name' },
    { id:'lastname', header: "User LastName", width: 75, sortable: true, dataIndex: 'lastname' },
    { id:'age', header: "User Age", width: 75, sortable: true, dataIndex: 'age' }
    ]
    });

    app/store/ListeStore.js

    Ext.define('PHPExtJS4.store.ListeStore', {
    extend: 'Ext.data.JsonStore',
    proxy: {
    type: 'ajax',
    url: 'data/store.php',
    reader: {
    type: 'json',
    root: 'liste'
    }
    }
    fields: ['userID', 'name', 'lastname', 'age']
    });
    Attached Images

  2. #2
    Sencha User
    Join Date
    Dec 2010
    Location
    SC - Brazil
    Posts
    27
    Vote Rating
    4
    Answers
    3
    Renan Cunha is on a distinguished road

      0  

    Default


    The Ext JS made the request to the server? You already debugged the result using some tool like Chrome Developer Tools or Firebug?

  3. #3
    Sencha User
    Join Date
    Dec 2012
    Posts
    42
    Vote Rating
    1
    Answers
    2
    muceli is on a distinguished road

      0  

    Default


    "Uncaught TypeError: Cannot read property 'buffered' of undefined"it gave an error message

Thread Participants: 1

Tags for this Thread