如何在代码点火器中创建一个带有从另一个控制器传递的变量的柔性网格?
我的问题有点愚蠢,但我不知道该怎么做。我正在使用标准结构创建一个标准 Flexigrid:
//ver lib
/*
* 0 - display name
* 1 - width
* 2 - sortable
* 3 - align
* 4 - searchable (2 -> yes and default, 1 -> yes, 0 -> no.)
*/
$colModel['users.id'] = array('id',40,TRUE,'center',1);
$colModel['users.first_name'] = array('first_name',80,TRUE,'center',0);
$colModel['users.last_name'] = array('last_name',180,TRUE,'left',1);
$colModel['users.email'] = array('email',120,TRUE,'left',0);
$colModel['users.username'] = array('username',130, TRUE,'left',0);
$colModel['users.activation_code'] = array('activation_code',80, FALSE, 'right',0);
$colModel['users.activated'] = array('activated',80, FALSE, 'right',0);
$colModel['lists'] = array('Lists',90, FALSE, 'right',0);
/*
* Aditional Parameters
*/
$gridParams = array(
'width' => 'auto',
'height' => 400,
'rp' => 15,
'rpOptions' => '[10,15,20,25,40]',
'pagestat' => 'Displaying: {from} to {to} of {total} items.',
'blockOpacity' => 0.5,
'title' => 'Hello',
'showTableToggleBtn' => true
);
/*
* 0 - display name
* 1 - bclass
* 2 - onpress
*/
$buttons[] = array('Delete','delete','test');
$buttons[] = array('separator');
$buttons[] = array('Select All','add','test');
$buttons[] = array('DeSelect All','delete','test');
$buttons[] = array('separator');
//Build js
//View helpers/flexigrid_helper.php for more information about the params on this function
$grid_js = build_grid_js('flex1',site_url("admin/users/list_users"),$colModel,'users.first_name','asc',$gridParams,$buttons);
$data['js_grid'] = $grid_js;
$this->load->view('admin_panel/admin_content', $data);
现在我的问题是:是否可以在第三个 URI 段中创建带有参数的 Flexigrid?例如,我想显示一个用户创建的列表,为此我需要他的 ID。我可以在同一个控制器中轻松地做到这一点,但我想将其传递到不同的控制器并在那里创建新的 Flexigrid 表单。那么在 'index()' 方法中我可以拥有从不同控制器传递的 $get_id 变量吗?像这样?
$grid_js = build_grid_js('flex1',site_url("admin/admin_lists/display_show_list/".$get_id),$colModel,'name','asc',$gridParams,$buttons);
我希望我能很好地解释我的问题。有人可以给我一些帮助吗?非常感谢任何提示!
My problem is kinda silly but I don't know how to do it. I'm creating a standard flexigrid using standard structure:
//ver lib
/*
* 0 - display name
* 1 - width
* 2 - sortable
* 3 - align
* 4 - searchable (2 -> yes and default, 1 -> yes, 0 -> no.)
*/
$colModel['users.id'] = array('id',40,TRUE,'center',1);
$colModel['users.first_name'] = array('first_name',80,TRUE,'center',0);
$colModel['users.last_name'] = array('last_name',180,TRUE,'left',1);
$colModel['users.email'] = array('email',120,TRUE,'left',0);
$colModel['users.username'] = array('username',130, TRUE,'left',0);
$colModel['users.activation_code'] = array('activation_code',80, FALSE, 'right',0);
$colModel['users.activated'] = array('activated',80, FALSE, 'right',0);
$colModel['lists'] = array('Lists',90, FALSE, 'right',0);
/*
* Aditional Parameters
*/
$gridParams = array(
'width' => 'auto',
'height' => 400,
'rp' => 15,
'rpOptions' => '[10,15,20,25,40]',
'pagestat' => 'Displaying: {from} to {to} of {total} items.',
'blockOpacity' => 0.5,
'title' => 'Hello',
'showTableToggleBtn' => true
);
/*
* 0 - display name
* 1 - bclass
* 2 - onpress
*/
$buttons[] = array('Delete','delete','test');
$buttons[] = array('separator');
$buttons[] = array('Select All','add','test');
$buttons[] = array('DeSelect All','delete','test');
$buttons[] = array('separator');
//Build js
//View helpers/flexigrid_helper.php for more information about the params on this function
$grid_js = build_grid_js('flex1',site_url("admin/users/list_users"),$colModel,'users.first_name','asc',$gridParams,$buttons);
$data['js_grid'] = $grid_js;
$this->load->view('admin_panel/admin_content', $data);
Now my question is: is it possible to create a flexigrid WITH a parameter in third URI segment? For instance, I want to display a list, which user created and to do that I need his id. I can easily do that within the same controller but I want to pass it to different controller and create new flexigrid form there. So in 'index()' method can I have, for instance $get_id variable passed from different controller? Like this?
$grid_js = build_grid_js('flex1',site_url("admin/admin_lists/display_show_list/".$get_id),$colModel,'name','asc',$gridParams,$buttons);
I hope I explained my problem well enough. Can someone give me some help with this? Mostly appreciated for any hints!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有两种方法可以实现此目的:
您应该创建一个帮助器来代替使用控制器来构建网格结构。请参阅http://codeigniter.com/user_guide/general/helpers.html
只需将函数包装在助手中即可。
在控制器中创建一个函数,如下所示:
//in controller
//in View (Javascript)
There are 2 ways you can achieve this:
Instead of using a controller to build your grid structure, you should create a helper to do it instead. Refer to http://codeigniter.com/user_guide/general/helpers.html
Simply wrap the function in a helper will do.
Create a function in controller like such:
//in controller
//in View (Javascript)