rapyd-framework
rapyd-framework copied to clipboard
Please give some examples of grid setSource
I want to deal with special fields in the model In the model code:
public function datagrid($industries = array()){
$data = $this->get();
foreach ($data as &$value) {
$_industries = array();
$_temp = explode(',', $value->industries);//The database field values:1,2,3
foreach ($_temp as $val) {
if(isset($industries[$val])){
$_industries[] = $industries[$val];
}
}
$value->industries = $_industries;//After processing the value of the:array('餐饮','酒店','其他');
}
return $data;
}
In the controller code:
$industries = array(array('id'=>1, 'name'=>'餐饮'), array('id'=>2, 'name'=>'酒店'), array('id'=>3, 'name'=>'其他', ));
$adsense = new Adsense();
$data = $adsense->datagrid($industries)
$dg->setSource($data);
Please help me, thank you