我的问题有点傻但我不知道怎么做。我正在使用标准结构创建标准的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);
我希望我能很好地解释我的问题。有人可以给我一些帮助吗?非常感谢任何提示!
答案 0 :(得分:2)
有两种方法可以实现这一目标:
只需将函数包装在帮助程序中即可。
在控制器中创建一个函数,如:
//在控制器中
function makeGrid() {
$id = $this->uri->segment(3);
$grid_js = .....;
echo json_encode($grid_js);
}
//在View(Javascript)
中$.ajax({
url:"/path/makeGrid" + id
...
success: function(data){
$.flexigrid( {... data .... });
}