Hybrid View

  1. #1
    Sencha User
    Join Date
    Jun 2010
    Posts
    3
    Vote Rating
    0
    variedmind is on a distinguished road

      0  

    Post Unanswered: ExtJs 4 + PHP + MySQL

    Unanswered: ExtJs 4 + PHP + MySQL


    I want to show certain data from a MySql table to ExtJs Datagrid.using PHP.
    I have searched alot but there are no threads on this topic
    I found one but with ExtJs 2

  2. #2
    Sencha User
    Join Date
    Feb 2011
    Posts
    174
    Answers
    10
    Vote Rating
    1
    netemp is on a distinguished road

      0  

    Default Here is sample code

    Here is sample code


    Hope you have gone through examples - http://docs.sencha.com/ext-js/4-0/#!/example/grid/array-grid.html

    B
    elow is a small sample hoping that you are looking for the same:

    Code:
    //Define the model below, map the fields in your JSON coming from the server to the field names in this model
    
    Ext.define('GridModel', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'company', type: 'string'},
            {name: 'price', type: 'string'},
            {name: 'change', type: 'string'},
            {name: 'pctChange', type: 'string'}
        ]
    });
    
    
    //Define the store below, providing it the Model and the URL of PHP file
    
    var storeVar = Ext.create('Ext.data.Store', {
        pageSize: 5,
        model: 'GridModel',
        proxy: {
            type: 'ajax',
            url : 'stores_page_grid.php',
            reader: {
                type: 'json'
            },
            extraParams:{
                action:'pagingTestGrid'
            }
        },
        autoLoad: false
    });
    
    
    
    
    // create the Grid
    
    var grid = Ext.create('Ext.grid.Panel', {
        id:'gridId',
        store: storeVar,
        columns: [
            {
                text     : 'Company',
                flex     : 1,
                sortable : false,
                dataIndex: 'company'
            },
            {
                text     : 'Price',
                width    : 75,
                sortable : true,
                dataIndex: 'price'
            },
            {
                text     : 'Change',
                width    : 75,
                sortable : true,
                dataIndex: 'change'
            },
            {
                text     : '% Change',
                width    : 75,
                sortable : true,
                dataIndex: 'pctChange'
            }
        ],
        // paging bar on the bottom
        bbar: Ext.create('Ext.PagingToolbar', {
            store: storeVar,
            displayInfo: true,
            displayMsg: 'Displaying topics {0} - {1} of {2}',
            emptyMsg: "No topics to display"
        }),
        height: 350,
        width: 600,
        title: 'Array Grid',
        renderTo: 'grid-example',
        viewConfig: {
            stripeRows: true
        }
    });
    Hope this helps.

  3. #3
    Sencha User
    Join Date
    Jun 2010
    Posts
    3
    Vote Rating
    0
    variedmind is on a distinguished road

      0  

    Post Hi

    Hi


    I need example with PHP + Mysql not jason

  4. #4
    Sencha User
    Join Date
    Jun 2010
    Posts
    3
    Vote Rating
    0
    variedmind is on a distinguished road

      0  

    Default


    Thank you but I need example with PHP + Mysql not jason

  5. #5
    Sencha User
    Join Date
    Sep 2010
    Location
    Pune,India
    Posts
    23
    Vote Rating
    0
    rvaibhav is on a distinguished road

      0  

    Default


    You can use PHP script to query data from mySQL and use json_encode to return that data.

Thread Participants: 2

Tags for this Thread