Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter + ExtJS 2.2 ? Tutorial?
#6

[eluser]aexer[/eluser]
I want to create some grids with extjs and load the data with codeigniter in it. I see the head of the extjs grid table, but no data inserted. Above i see the json encoded strin like this.

Code:
({"total":"11","results":[{"man_id":"1","firmenname":"Aexer.com - Webdesign & Coding","name":"Exer","vorname":"Andi","ort":"Felsberg"},{"man_id":"2","firmenname":"Bijouterie Exer-Salzgeber","name":"Salzgeber","vorname":"Menga","ort":"St. Moritz"},{"man_id":"3","firmenname":"Hubbi GMBH","name":"Dietrich","vorname":"Hubertus","ort":"Chur"},{"man_id":"6","firmenname":"Exerson Maschinen","name":"Exer","vorname":"Rolf","ort":"St.Gallen"},{"man_id":"7","firmenname":"Tschie","name":"Heller","vorname":"Marco","ort":"M\u00fcnchen"},{"man_id":"9","firmenname":"adsf","name":"asdf","vorname":"asdf","ort":"Dresden"},{"man_id":"10","firmenname":"Testkunde","name":"Test","vorname":"test","ort":"test"},{"man_id":"11","firmenname":"test","name":"testfeld1t","vorname":"test","ort":"st"},{"man_id":"12","firmenname":"Form Check Company","name":"Form","vorname":"Check","ort":"Name check"},{"man_id":"13","firmenname":"test","name":"test","vorname":"trest","ort":"test"},{"man_id":"14","firmenname":"xait.ch","name":"Eugster","vorname":"Max","ort":"Chur"}]})

extjs.php controller
Code:
class Extjs extends Controller
        {
            function __construct()
                {
                    parent::Controller();
                    $this->load->model('m_extjs');
                    
                }
                
            function index()
            {
                $this->load->view('main-grid');
            }
            
            function js_listBoards()
            {
                $Boards = $this->m_extjs->getBoards();
            
                foreach($Boards->result() as $row)
                {
                    $item = Array("man_id" => $row->man_id,
                                  "firmenname" => $row->firmenname,
                                  "name" => $row->name,
                                  "vorname" => $row->vorname,
                                  "ort" => $row->ort);
            
                    $itemList[] = $item;
                }
            
                $rows = $Boards->num_rows();
                $data = json_encode($itemList);
                
                 echo '({"total":"' . $rows . '","results":' . $data . '})';
            
                $this->load->view('main-grid');
            }
            
        }

m_extjs.php
Code:
class M_extjs extends Model
        {
            
            function __construct()
            {
                parent::Model();
            }    
        
            function getBoards()
            {
              
                $lBoards = $this->db->get('tbl_mandat');
                return $lBoards;
            }
        
        }

grid.js
Code:
Ext.onReady(function(){        
    var dataRecord = new Ext.data.Record.create([
        {name: 'man_id'},
        {name: 'firmenname'},
        {name: 'name'},
        {name: 'vorname'},
        {name: 'ort'}
    ]);

    var dataReader = new Ext.data.JsonReader({
        root: 'results'
        },
        dataRecord
    );
    
    

    var dataProxy = new Ext.data.HttpProxy({
        url: '../../../index.php?c=extjs&m=js_listboards',
        method: 'POST'
    });
    
    var dataStore = new Ext.data.Store({
            proxy: dataProxy,
            reader: dataReader
        });

    var colModel = new Ext.grid.ColumnModel([
        {header: "man_id", sortable: true, dataIndex: 'man_id'},
        {header: "firmenname", dataIndex: 'firmenname'},
        {header: "name", dataIndex: 'name'},
        {header: "vorname", sortable: true, dataIndex: 'vorname'},
       {header: "ort", sortable: true, dataIndex: 'ort'}
    ]);

    var grid = new Ext.grid.GridPanel({
        autoHeight: true,
        renderTo: 'mainGrid',
        store: dataStore,
        id: 'mainGrid',
        width: 740,
        viewConfig: {
            forceFit: true
        },
        cm: colModel
    });

    dataStore.load();
This app is the tutorial from the extjs website

Any ideas?

thx for help

regards aexer


Messages In This Thread
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 02-12-2009, 07:18 AM
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 02-12-2009, 01:26 PM
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 02-12-2009, 01:39 PM
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 02-12-2009, 03:01 PM
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 02-12-2009, 04:47 PM
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 02-18-2009, 03:50 AM
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 02-18-2009, 07:33 AM
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 02-18-2009, 09:22 AM
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 02-18-2009, 09:24 AM
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 02-18-2009, 09:37 AM
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 02-18-2009, 09:41 AM
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 02-18-2009, 05:48 PM
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 04-23-2009, 03:37 PM
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 07-28-2009, 12:30 AM
CodeIgniter + ExtJS 2.2 ? Tutorial? - by El Forum - 09-05-2009, 09:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB