configure flexigrid helper, and customize variable $colModel

577 Views Asked by At

I try to start Flexigrid into Codeigniter.

I download demo files from here
http://gembelzillonmendonk.wordpress.com/2010/06/28/flexigrid-and-codeigniter-with-advanced-searching-with-example/

but i wrong to set up something:

Instruction from site:

  • extract .rar to CI folder**
  • open your controller (ie: CI_Folder\system\application\controllers\flexigrid.php)**
  • configure flexigrid helper, and customize variable $colModel, example:**

    code example

What I did:

  • I installed correctly CodeIgniter (copy and paste inside htdocs - xampp)
  • I created a database called 'country' and import sql file inside demo.
  • I copied correctly files an folders from demo files to my CI folder (called grocery-crud-demo).

But when I type on firefox http://localhost/grocery-crud-demo/index.php/flexigrid/index I have this error

Fatal error: Class 'Controller' not found in C:\xampp\htdocs\grocery-crud-demo\application\controllers\flexigrid.php on line 2
A PHP Error was encountered

Severity: Error

Message: Class 'Controller' not found

Filename: controllers/flexigrid.php

Line Number: 2

Backtrace:

I read instruction also from here: http://roadmyapps.toile-libre.org/index.php/flexigrid/example
but I don't understand which code exactly I must have into flexigrid.php

I don't understand how configure flexigrid helper, and customize variable $colModel.

I need exact code into files. Have you idea?


I find CodeIgniter 1.7.3 -- I repeat steps -- new error:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Ajax_model::$db

Filename: models/ajax_model.php

Line Number: 34

Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\grocery-crud-demo\system\application\models\ajax_model.php on line 34

Code of ajax_model.php is this: http://pastebin.com/P3KawC7S

1

There are 1 best solutions below

3
Tpojka On

Probably you are using newer version of CI than one on tutorial. As I can see tutorial is written for 1.7.2 version.

Try to change

class Someclass extends Controller
{
  public function someclass()
  {
  }
  public function index()
  {
    //etc, etc
  }
}

with

class Someclass extends Controller
{
  public function __construct()
  {
    parent::__construct()
    {
    }
  }
  public function index()
  {
    //etc, etc
  }
}

Also, for models too. Like

public function Ajax_model()
{
    parent::Model();
    $this->CI =& get_instance();
}

should be

public function __construct()
{
    parent::__construct();
    $this->CI =& get_instance();
}

Try that way. Spot those differences. Those should change in every controller and model respectivelly. Follow this link for upgrading your app. If fail again, see the CodeIgniter documentation about upgrading versions.