问题
I am new to yii framework i have created an yii web application with one module . Now my question is i have added an sample data into my module in my module i have an columns name,dept and and active ,i want to render the data in the grid view only the data where active=0 , Can anyone help me how to change the data rendering query and how to add the condition
<div class="block">
<div class="content">
<h2 class="title">Users's details</h2>
<div class="inner">
<?php $this->widget('zii.widgets.CDetailView', array(
'data' => $model,
'attributes' => array(
'user_id',
'user_name',
'userpass',
'userdept',
'active',
),
'itemTemplate' => "<tr class=\"{class}\"><td style=\"width: 120px\"><b>{label}</b></td><td>{value}</td></tr>\n",
'htmlOptions' => array(
'class' => 'table',
),
)); ?>
</div>
</div>
Thanks in advance.
回答1:
Try adding a criteria
$criteria->compare('active', '1');
回答2:
You have to add this in your search function:
$criteria->compare('active', '1');
来源:https://stackoverflow.com/questions/15240588/yii-index-view-data-rendering-with-condition