簡體   English   中英

phpGrid_Lite在CodeIgniter-3.1.7上不顯示網格

[英]phpGrid_Lite doesnt show grid on CodeIgniter-3.1.7

我已經從官方網頁https://phpgrid.com/example/phpgrid-and-codeigniter-integration/遵循了該教程,但是我的視圖沒有顯示網格,我的數據庫名為phpGrid並有一個表producto ,這個問題只發生在CI上,因為我已經測試沒有CI的phpGrid_Lite並且可以很好地顯示網格。

(對不起,我的英語不好 :))

這是我的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
}

最后這就是結果

您是否配置了CI以使用本機PHP會話? 由於CI3中的權限更新,您可能還需要在應用程序文件夾中添加.htaccess

我在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>

希望這對您有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM