我想要编辑&查看按钮将显示在浏览器中。我不知道应修改哪些代码以使按钮进入浏览器。 我已经链接了按钮助手,但我不知道。任何人都可以在我的代码中提出任何建议的修改,因为我是&flex;新的' flexigrid'。
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Plan extends MY_Controller {
function __construct()
{
parent::__construct();
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->model('plan_model');
$this->template->add_js('js/default.js');
$this->load->helper('buttons');
$this->accessible(10,'v');
}
public function index($msg='')
{
if($msg!='')
$data['msg']=$msg;
else
$data['msg']='';
$this->template->add_css('flexigrid/css/flexigrid.css');
$this->template->add_js('flexigrid/flexigrid.js');
$header = array(
array('display' => 'ID', 'name' => 'plan_id', 'width' => 50, 'sortable' => true, 'align' => 'center', 'hide' => true),
array('display' => 'Plans Name', 'name' => 'plan_name', 'width' => 120, 'sortable' => true, 'align' => 'left'),
array('display' => 'Validity (years)', 'name' => 'def_sub_years', 'width' => 120, 'sortable' => true, 'align' => 'left'),
array('display' => 'Plan Amount', 'name' => 'plan_amount', 'width' => 100, 'sortable' => true, 'align' => 'left'),
array('display' => 'Action', 'name' => 'action', 'width' => 150, 'align' => 'left')
);
$colModel = json_encode($header);
$action = array();
$buttons = str_replace(array('"^','^"'),'',json_encode($action));
$filter = array (
array('display' => 'Plan Name', 'name' => 'entity_name', 'isdefault' => true),
);
$searchitems = json_encode($filter);
$properties = array (
'url' => base_url()."index.php/plan/get_plan",
'colModel' => $colModel,
'buttons' => $buttons,
'searchitems' => $searchitems,
'sortname' => "id",
'sortorder' => "asc",
'title' => "Plans",
'usepager' => true,
'useRp' => true,
'rp' => 10,
'showTableToggleBtn'=> true,
'width' => "auto",
'height' => "auto"
);
/*Flexigrid helper for grid view.*/
$this->load->helper('flexigrid');
$data['flexigrid'] = flexigrid("tbl_plan",$properties);
$this->template->add_js($data['flexigrid'] , 'embed');
$data['title'] = 'Plans';
$this->template->write_view('content', 'plan/index', $data);
$this->template->render();
}
function get_plan()
{
$action_data = array();
$access_data = array();
$data['page'] = $this->input->post('page');
$data['rp'] = $this->input->post('rp');
$data['sortname'] = $this->input->post('sortname');
$data['sortorder'] = $this->input->post('sortorder');
$data['query'] = $this->input->post('query');
$data['qtype'] = $this->input->post('qtype');
$result = $this->plan_model->get_plan($data);
$field = array(0=>'id',1=>'plan_name',2=>'def_sub_years',3=>'plan_amount');
$total = $result['total'];
unset($result['total']);
foreach($result as $rslt)
{
/* if($rslt['id'] == ($this->settings_model->org_admin()))
{*/
$action_data[$rslt['id']] = array('view' => 'plan/edit_plan/','edit' => 'plan/edit_plan/','delete' => '');
$access_data[$rslt['id']] = array('view' => $this->has_access(10,'v'),'edit' => $this->has_access(10,'m'),'delete' => '');
//}
}
echo $this->settings_model->json_format($result,$field,$action_data,$access_data,$total,false,$data['page']);
}
function edit_plan($id,$action)
{
$this->accessible(10,$action);
$data['flag'] = 0;
$data['plan_id'] = $id;
if($data['plan_id'] == 0)
$data['plan_info'] = array('id'=>0,'plan_name'=>NULL,'def_sub_years'=>NULL,'plan_amount'=>NULL,'action'=>$action);
else
{
$data['plan_info'] = $this->plan_model->plan_info($data['plan_id']);
$data['plan_info']['action'] = $action;
}
$data['title'] = 'Plan';
$this->template->write_view('content', 'plan/edit', $data);
$this->template->render();
}
}
?>
答案 0 :(得分:1)
从代码中,我们将id,plan_name,def_sub_years和action传递给$ field变量,因此我们必须添加4 =&gt;'action'将使按钮显示在浏览器中。
$field = array(0=>'id',1=>'plan_name',2=>'def_sub_years',3=>'plan_amount',4=>'action');