ajax 请求调用以下操作,其响应为 JSON:
\Yii::$app->response->format = 'json';
if($userId){
$dataProvider = new ArrayDataProvider([
'allModels' => Templates::getTemplates($userId,'n'),
]);
$response = $this->renderAjax('index', ['dataProvider' => $dataProvider,]);
return ['status'=>true,'data'=>$response,'total'=>count($dataProvider)];
}
Run Code Online (Sandbox Code Playgroud)
在这个action的View中,有一个GridView Widget:
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'id',
[
'attribute'=> 'template_name',
'label'=>'Test Name',
'value' => function($data){
$url = Yii::$app->urlManager->createUrl('templates/get-tests')."&id=".$data->id;
return '<a href="'.$url.'" title="'.Html::encode($data->template_name).'">'.Html::encode($data->template_name).'</a>';
}
],
[
'attribute'=> 'template_date',
'label'=>'Beginning Date'
],
[
'attribute'=> 'template_expire_time',
'label'=>'End Date'
],
'user_id',
],
]); ?>
Run Code Online (Sandbox Code Playgroud)
但这对模板名称的 html 值进行编码。例如:测试 <a href="test.php">测试</a>
我不需要这种编码。请帮我解决这个问题。
构造函数可以在C++中是私有的吗?如果是,那我们怎么称呼呢?
class Puma
{
int a = 10;
Puma()
{
cout << a;
}
};
int main()
{
Puma pum;
return o;
}
Run Code Online (Sandbox Code Playgroud)
这个程序可以运行吗?如果没有那么我们如何调用Puma()构造函数,因为它是私有的?