简体   繁体   中英

phpGrid_Lite doesnt show grid on CodeIgniter-3.1.7

I have followed the tutorial from the official webpage https://phpgrid.com/example/phpgrid-and-codeigniter-integration/ but my view doesn't show the grid, my database is called phpGrid and have a table producto , this problem only occur with CI, because i have tested phpGrid_Lite without CI and works fine showing the grid.

(sorry for my bad english :))

this is my Welcome controller

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Welcome extends CI_Controller {

    public function index()
    {
        //$this->load->view('welcome_message');

        require_once(APPPATH. 'libraries/phpGrid_Lite/conf.php'); // APPPATH is path to application folder
        $data['phpgrid'] = new C_DataGrid("SELECT * FROM producto", "id", "producto"); //$this->ci_phpgrid->example_method(3);

        $this->load->view('show_grid',$data);
    }
}

and here is my show_grid.php file

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Show Grid</title>
</head>
<body>

<div id="container">
<h1>Welcome to CodeIgniter! Show me the grid!</h1>

<div id="body">
    <?php $phpgrid->display(); ?>
</div>

</div>

</body>
</html>

the conf.php

<?php
/**/
if (stripos($_SERVER['SCRIPT_NAME'], 'apps/phpgrid-custom-crm')) {
define('PHPGRID_DB_HOSTNAME', '127.0.0.1'); // database host name
define('PHPGRID_DB_USERNAME', 'root');     // database user     name
define('PHPGRID_DB_PASSWORD', ''); // database password
define('PHPGRID_DB_NAME', 'phpGrid'); // database name
define('PHPGRID_DB_TYPE', 'mysql');  // database type
define('PHPGRID_DB_CHARSET','utf8'); // ex: utf8(for mysql),AL32UTF8 (for oracle), leave blank to use the default charset
} else {
//* mysql example 
define('PHPGRID_DB_HOSTNAME','localhost'); // database host name
define('PHPGRID_DB_USERNAME', 'root');     // database user name
define('PHPGRID_DB_PASSWORD', ''); // database password
define('PHPGRID_DB_NAME', 'phpGrid'); // database name
define('PHPGRID_DB_TYPE', 'mysql');  // database type
define('PHPGRID_DB_CHARSET','utf8'); // ex: utf8(for mysql),AL32UTF8 (for         oracle), leave blank to use the default charset
}

and finally this is the result

Did you configure CI to use native PHP session? You may also need to add .htaccess in the application folder due to permission update in CI3.

I ran into the same problem with CI and phpgrid Lite and this is how I got the grids to appear. I moved the assets folder from the application/library so it is in the same folder as the application folder and the system folder.

Then I altered these parts of the controller and view.

Controller:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Welcome extends CI_Controller {

    public function index()
    {
     require_once('assets/phpGrid_Lite/conf.php');
     $dg = new C_DataGrid("SELECT * FROM Orders", "orderNumber", "Orders"); //$this->ci_phpgrid->example_method(3);
     $dg -> set_multiselect(true);
     $dg -> enable_search(true);

     $dg->display(false);
     $data['phpgrid'] = $dg->get_display(true);

     $this->load->view('show_grid',$data);
    }

}

In the View file show_grid.php

View:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Show Grid</title>
</head>
<body>

<div id="container">
<h1>Welcome to CodeIgniter! Show me the grid!</h1>

<div id="body">
    <?= $phpgrid; ?>
</div>

</div>

</body>
</html>

Hope this works for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM