I just looked at the source files of PHPgrid, and it seems that they are encrypted, so you are limited in how you can fully "integrate" with the Codeigniters MVC framework.
To work with an external library like this, here is what I usually did:
Save a separate config.php file (which is similar to PHPgrid) that defines the db connection constants in the root directory.
Then require this in the codeigniter config / database.php file and use constants to set the Codeigniter parameters. So your Codeigniter database.php will look like this:
require_once('config.php'); $db['default']['hostname'] = DB_HOSTNAME; $db['default']['username'] = DB_USERNAME; $db['default']['password'] = DB_PASSWORD; $db['default']['database'] = DB_NAME;
You do not want to store database connection data everywhere.
Then include config.php at the top of your phpgrid / conf.php file and use constants to fill in the details in the same way, obviously fill in the rest of the phpgrid constants.
Put all the PHPgrid files in the application / library subdirectory. Now create a new file in your application / library file called something like ci_phpgrid.php, and create a new class in it, as shown below:
<?php require_once('phpgrid/conf.php'); class CI_phpgrid { public function example_method($val = '') { $dg = new C_DataGrid("SELECT * FROM Orders", $val, "Orders"); return $dg; } }
Now you can use this to communicate with the php network, leaving the source files intact.
In your controller, you just do something like:
$this->load->library('ci_phpgrid'); $data['phpgrid'] = $this->ci_phpgrid->example_method(3) $this->load->view('home_page',$data);
And then in the view, you can display the table using:
$phpgrid->display()
As I mentioned, I did not use PHPgrid, and you will need to include all the relevant JSs for sorting, etc., but this is usually the way you want to access external libraries in CI.