1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    3
    Vote Rating
    0
    himono_onna is on a distinguished road

      0  

    Default Filter grid by remote filter (from MySQL table)

    Filter grid by remote filter (from MySQL table)


    Dear all,

    I'm newbie in extjs. I've learning about grid filtering from local filter (data store). I make a grid using simple basic code (not use extjs MVC), but the result wasn't I expected as described below picture : filtering comparison.jpg

    And here is my code :
    1) grid.js
    HTML Code:
    <script type="text/javascript">
            Ext.Loader.setConfig({enabled: true});
            Ext.Loader.setPath('Ext.ux', 'ux');
            Ext.require([
                'Ext.ux.grid.FiltersFeature',
            ]);
    
            Ext.onReady(function(){
                 var store = Ext.create('Ext.data.Store', {
                    fields: [
                         {name: 'nama', type: 'string'},
                         {name: 'kelompok',  type: 'string'},
                         {name: 'entity',  type: 'string'}
                    ],
                    pageSize: 10, 
                    autoLoad: { start: 0, limit: 10 }, 
                    proxy: {
                        type: 'ajax', 
                        url : 'data.php',
                        reader: {
                            root: 'results', 
                            totalProperty: 'jumlah' 
                        }
                    }
                });
                
                var filtersCfg = {
                    ftype: 'filters', 
                    autoReload: false,
                    local: true 
                };
                
                Ext.create('Ext.grid.Panel', {
                    title: 'Date Column Demo', 
                    store: store, 
                    columns: [ 
                        { text: 'No', xtype: 'rownumberer' },
                        { text: 'Name', dataIndex: 'nama', flex: 1, sortable: true, filter: { type: 'string' } },
                        { text: 'Group', dataIndex: 'kelompok', sortable: true, filter: { type: 'string' } },
                        { text: 'Entity', dataIndex: 'entity', sortable: true, filter: { type: 'string' } }      
                    ],
                    features: [filtersCfg], 
                    height: 320,
                    width: 450,                
                    dockedItems: [{ 
                        xtype: 'pagingtoolbar',
                        store: store,   
                        dock: 'bottom', 
                        displayInfo: 'true', 
                        displayMsg: "Displaying {0} - {1} of {2} data", 
                        emptyMsg: "Data not found" 
                    }],
                    enableColumnMove: true, 
                    renderTo: Ext.getBody() 
                });
                    
            });
        </script>
    2) data.php
    [PHP]
    $db = mysql_connect("localhost","root","") or die ("Koneksi Gagal");
    mysql_select_db("db_billing_system",$db) or die ("Koneksi ke database gagal");
    
    $sq = mysql_query("SELECT a.* FROM m_blok AS a WHERE a.is_deleted = 0") or die (mysql_error());
    $count = mysql_num_rows($sq);
    
    $sql = mysql_query("SELECT a.*, b.`value` AS kelompok, c.`value` AS entity
                        FROM m_blok AS a 
                        JOIN m_system_codes AS b ON a.kelompok_id = b.`code` AND b.`key` = 'kelompok'
                        JOIN m_system_codes AS c ON a.entity_id = c.`code` AND c.`key` = 'entity'
                        WHERE a.is_deleted = 0
                        ORDER BY a.nama LIMIT " . $_GET["start"] . "," . $_GET["limit"]) or die (mysql_error());
    
    $data = array();
    while ($rs = mysql_fetch_object($sql)) {
        $data[] = $rs;
    }
    
    echo '({"jumlah":"'.$count.'","results":'.json_encode($data).'})';
    [/PHP]
    
    The question now is, how do I change my code, so I can get the result as I expect.
    Hope somebody can help me. Thanks

  2. #2
    Sencha User Legolas's Avatar
    Join Date
    Apr 2010
    Location
    Brazil/MG
    Posts
    58
    Vote Rating
    3
    Legolas is on a distinguished road

      0  

    Default


    Hi himono_onna,

    Your data is being filtered local and not remote because the property local is true in your plugin cfg. In this case you should change the value in property local to false. So the filter parameter will be sent for your server side.
    I am sorry my english, I am learning yet
    Portuguese blog: http://wessdevel.blogspot.com.br/
    Twitter: @wlegolas

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    3
    Vote Rating
    0
    himono_onna is on a distinguished road

      0  

    Default


    Hi Legolas,

    About your quote, don't worry about it . You can use google translate if you have a trouble with grammar or vocabulary (I also use it to write this posting )
    Thank for your suggestion, but I'm sorry, it doesn't work.

    I want the data to be filtered can be displayed in full (no leap of data or having to move the page to search for data from filtering results). If you ever use flexigrid and codeigniter, you'll know what I mean.

    Regards,
    himono_onna

  4. #4
    Sencha User Legolas's Avatar
    Join Date
    Apr 2010
    Location
    Brazil/MG
    Posts
    58
    Vote Rating
    3
    Legolas is on a distinguished road

      0  

    Default


    Quote Originally Posted by himono_onna View Post
    About your quote, don't worry about it . You can use google translate if you have a trouble with grammar or vocabulary (I also use it to write this posting )
    I use sometimes when I do not understand the doubt
    Quote Originally Posted by himono_onna View Post
    Thank for your suggestion, but I'm sorry, it doesn't work.

    I want the data to be filtered can be displayed in full (no leap of data or having to move the page to search for data from filtering results). If you ever use flexigrid and codeigniter, you'll know what I mean.
    I never used flexigrid and codeigniter, but do try to use the Sencha example: Custom Grid Filters Example (local filtering) change this to remote.
    I have this example, but is used version ExtJS3 and in portuguese, maybe can help you to find a solution.
    I am sorry my english, I am learning yet
    Portuguese blog: http://wessdevel.blogspot.com.br/
    Twitter: @wlegolas

  5. #5
    Sencha User
    Join Date
    Feb 2013
    Posts
    3
    Vote Rating
    0
    himono_onna is on a distinguished road

      0  

    Default


    Quote Originally Posted by Legolas View Post
    I use sometimes when I do not understand the doubt

    I never used flexigrid and codeigniter, but do try to use the Sencha example: Custom Grid Filters Example (local filtering) change this to remote.
    I have this example, but is used version ExtJS3 and in portuguese, maybe can help you to find a solution.
    Thanks very much for your last solution. It works.
    And once again about google translate, it's really help me for translate your language in that forum

Thread Participants: 1