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

[eluser]aexer[/eluser]
Hiho everybody

I'm searching for a tutorial or a video tutorial to integrate ExtJS 2.2 into CodeIgniter. With the Tutorial on the site of extjs it won't work.

Has anybody a good tutorial for grids and so on?


Thx for help


aexer
#2

[eluser]Mirage[/eluser]
I don't have a tutorial, but I've integrating with Ext since before 2.0. I really don't see what's to integrate? ExtJs runs on the client and makes HTTP Requests. On the CI side of thing you do the same thing you'd do for regular browser requests. Except that your output is often not html, but rather JSON or XML.

Either way - CI itself has little to do with any of this...
#3

[eluser]simshaun[/eluser]
Mirage, you might wanna fix your site.
Looks like MS Office Smart Quotes got the best of you. lol Smile

Edit: Just noticed that those errors are all over the place.
#4

[eluser]Mirage[/eluser]
Smart Quotes? What Smart Quotes? :red:

Thanks for the heads up.
#5

[eluser]pistolPete[/eluser]
[quote author="aexer" date="1234466325"]I'm searching for a tutorial or a video tutorial to integrate ExtJS 2.2 into CodeIgniter[/quote]

What are you trying to do exactly? I don't know about a specific tutorial, but have a look at the JSON-Helper, which provides you a possibility to handle communication with ExtJS.
#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
#7

[eluser]aexer[/eluser]
Hello again Wink

So now extjs shows the header from the table.. but no data Sad

Screen of the Gridtest
#8

[eluser]Mirage[/eluser]
I think you need to return a success flag in your response. So:

Code:
echo '({"total":"' . $rows . '","results":' . $data . ', success: true })';
#9

[eluser]Mirage[/eluser]
Here's a compact example of how I put these things in my controllers:

Code:
function loadProperties() {
        $obj=new stdClass();
        try {
            $this->load->model('AbstractsModel','',true);
            $obj->data=$this->AbstractsModel->getProperties($_POST['id']);
        } catch (Exception $e) {
            $obj->success=false;
        }
        echo json_encode($obj);
    }
#10

[eluser]aexer[/eluser]
I changed my code to your source.. But it won't work:

Code:
echo '({"total":"' . $rows . '","results":' . $data . ', success: true })';




Theme © iAndrew 2016 - Forum software by © MyBB