【问题标题】:phpGrid_Lite doesnt show grid on CodeIgniter-3.1.7phpGrid Lite 在 CodeIgniter-3.1.7 上不显示网格
【发布时间】:2018-12-01 08:42:54
【问题描述】:

我是按照官网https://phpgrid.com/example/phpgrid-and-codeigniter-integration/的教程来的 但是我的视图没有显示网格,我的数据库名为 phpGrid 并且有一个表 producto,这个问题只发生在 CI 上,因为我已经测试过 phpGrid_Lite 没有 CI 并且可以正常显示网格。

(对不起我的英语不好:))

这是我的Welcome 控制器

<?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);
    }
}

这是我的show_grid.php 文件

<?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>

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
}

最后是this is the result

【问题讨论】:

    标签: php codeigniter continuous-integration phpgrid


    【解决方案1】:

    您是否将 CI 配置为使用原生 PHP 会话?由于 CI3 中的权限更新,您可能还需要 add .htaccess in the application 文件夹。

    【讨论】:

      【解决方案2】:

      我在使用 CI 和 phpgrid Lite 时遇到了同样的问题,这就是我让网格出现的方式。 我从应用程序/库中移动了资产文件夹,因此它与应用程序文件夹和系统文件夹位于同一文件夹中。

      然后我修改了控制器和视图的这些部分。

      控制器:

      <?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);
          }
      
      }
      

      在查看文件show_grid.php中

      查看:

      <?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>
      

      希望这对你有用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-05
        • 1970-01-01
        • 2018-10-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多