用户
 找回密码
 入住 CI 中国社区
搜索
查看: 4073|回复: 1
收起左侧

基于Kohada的Grid module

[复制链接]
发表于 2008-4-20 10:45:43 | 显示全部楼层 |阅读模式
原文出处:点击这里
以下是本人根据原文意思对使用方法进行中文化整理的结果,经实际试用,感觉不错,就是过于简单,以有后空再慢慢扩展它的功能。
原文件下载地址: grige.zip (2.33 KB, 下载次数: 10)
解压缩后把整个文件夹放到Kohada->modules目录里, 然后在config.php的适当位置添加如下字段:
PHP复制代码
$config['modules'] = array

    'modules/auth', // Authentication
    'modules/forge', // Form generation
    'modules/grige', // Grid generation
    // 'modules/kodoc', // Self-generating documentation
    // 'modules/media', // Media caching and compression
 
复制代码

看这些源代码,它真的很简单。
简短样例:
PHP复制代码
$grid = new Grid('admin/album/', 'Album list'); // instantiate a Grid
$grid->add_new_button('new', 'add new album'); //Adds the "create new" button to the grid
$grid->field('artist')->label('Artist'); // set the label for artist field. The label will be shown as a column heading
$grid->field('title')->label('Album');
$grid->field('year')->label('Year');
$grid->action_field('id') //the field, that will be passed to the link as a parameter
    ->label('Edit') //Column label
    ->url('admin/album/'.'edit') //the uri for building the link
    ->action('Edit'); // the row text
//the URL will look like that: http://localhost/kohanasvn/admin/album/edit/1
$grid->action_field('id') //See above
    ->label('Delete')
    ->url($this->base_uri.'delete')
    ->action('Delete');
$album = new Album_Model; //Getting albums
$album->orderby('title', 'asc')->where('published', 1);
$grid->datasource(
    $album->find_all()
);
$this->template->content = $grid; //Adding the grid to the page
复制代码

该样例不包含分页功能,建议你在实际应用中应用Pagination类库加以扩展。

[ 本帖最后由 szlinz 于 2008-4-21 09:43 编辑 ]

评分

参与人数 1威望 +5 收起 理由
Hex + 5 精品文章

查看全部评分

发表于 2008-4-23 09:42:19 | 显示全部楼层
怎么没人支持楼主啊????????

本版积分规则