首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >phpGrid_Lite没有在CodeIgniter-3.1.7上显示网格

phpGrid_Lite没有在CodeIgniter-3.1.7上显示网格
EN

Stack Overflow用户
提问于 2018-06-21 22:34:26
回答 2查看 418关注 0票数 0

我遵循了官方网页https://phpgrid.com/example/phpgrid-and-codeigniter-integration/中的教程,但我的视图没有显示网格,我的数据库名为phpGrid,有一个表producto,这个问题只在CI中出现,因为我测试了没有CI的phpGrid_Lite,并且很好地显示网格。

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

这是我的Welcome控制器

代码语言:javascript
复制
<?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文件

代码语言:javascript
复制
<?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

代码语言:javascript
复制
<?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
}

最后是这就是结果

EN

回答 2

Stack Overflow用户

发布于 2018-11-07 18:16:05

您是否将CI配置为使用本机PHP会话?您还可能需要在应用程序中添加.htaccess文件夹,因为CI3中的权限更新。

票数 2
EN

Stack Overflow用户

发布于 2018-11-12 00:26:18

我遇到了与CI和phpgrid相同的问题,这就是我如何让网格出现的原因。我将资产文件夹从应用程序/库中移出,因此它与应用程序文件夹和系统文件夹位于同一个文件夹中。

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

主计长:

代码语言:javascript
复制
<?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中

查看:

代码语言:javascript
复制
<?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>

希望这对你有用。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50978307

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档