When using CGridView, the filter input fields are automatically generated by the component.
I want to select which columns will show the input field. For example:
My model has 5 columns. I want CGridView to show the input filter ONLY for columns 1 and 2.
Is there a way to do it without using CSS or jQuery, just adding some code on the CGridView options?
array(
'name'=>'col3',
'value'=>'$data->col3',
'filter'=>false,
)
should work.
If you want to remove all filters form the entire CGridView, configure 'filterPosition'=>''
Only comments and filter disappears...
example:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'usuario-grid',
'dataProvider'=>$model->search(),
//'filter'=>'false',
'columns'=>array(
'rut_usuario',
....
Setting 'filter'=>false, is working for me.
You can put 'filter'=> false, but this attribute will minimize the witdh of the column.. another way to disable the filtering on a specific column is to return a input with attribute 'disabled' like:
'filter'=>'<input type="text" class="form-control" name="UsersSearch[password]"
disabled>',
Related
Is there any way to put into website template Selection field (fields.Selecton) of some model or dropdown selection of some model records ?
Or only one way is to call some python methods and get some data and then put it data into web page using JS ?
It turned out that you can add field using editor.
Also all fields are in the black list for website posting by default. To remove it from blacklist you will need to do stuff like this:
<function model="ir.model.fields" name="formbuilder_whitelist">
<value>crm.lead</value>
<value eval="[
'contact_name',
'description',
'email_from',
'name',
'partner_name',
'phone',
]"/>
</function>
I am using the code below display multiple selected values for users to choose from.
<div class="row">
<?php echo $form->labelEx($model,'site_staff'); ?>
<?php //echo $form->textField($model,'site_staff',array('size'=>60,'maxlength'=>255)); ?>
<?php //echo $form->dropDownList($model,'site_staff', CHtml::listData(Biodata::model()->findAll(), 'full_name', 'full_name'), array('empty'=>'Select')); ?>
<?php echo $form->dropDownList($model,'site_staff',CHtml::listData(Biodata::model()->findAll(),'full_name','full_name'),array('multiple'=>'true','prompt'=>'select ','selected'=>'selected'));?>
<?php echo $form->error($model,'site_staff'); ?>
</div>
I am trying to achieve the following but have no idea how to go about:
1) Add and remove function
- When a user choose one or more, by clicking "Add", will display the selected value in another dropdown list
- User can also remove any selected data in the latter dropdown list
So far, the single dropdown works well but users need to use CTRL-CLICK to select more than one option which is not a feasible way of selecting.
Any help is greatly appreciated.
Hii you can also use a multiselect dropdown for this.
Use yii select2 for this.
this is nice extension Please read more about this from here
http://www.yiiframework.com/extension/select2/
In odoo 8 the website is generated from Qweb templates. The webpages can also contain fields (say like in the 'Contact Us' form).
In the normal Odoo Form view it is easy to make a field invisible or readonly dynamically based on the user entry in some other field.
How can the similar thing be done in the Website view?
You can use a t-if statement, wrapped around the field you want to hide. Something like:
<div t-if="o.company_id">
<span t-field="o.company_id.partner_id.name">
</div>
In this example, the "name" field will be hidden if "company_id" is not set.
Here's a link to the QWeb reference.
If you want to omit some fields on dynamic basis. You can use "t-if" in your template, When you print it QWEB.
I used YII CListView and encoded true database id like PK column value before publish to HTML.
But also I find that CListView always shows these divs :-
div called "items" with all items and my artificial ids
hidden div called "keys" which nullifies step(i) since it dumps real
ids / PK of table
Can we not disable CListView from showing hidden div "keys" in output HTML?
I found out related post and looks like all required is to comment following line in CListView.run()
$this->renderKeys();
I hope this will not break pagination etc.
How to extend CListView in order to remove extra yii added markup?
i want to show grid view like magento
http://demo.magentocommerce.com/catalog/category/view/s/cellphones/id/8/
here we can see that multiple items are shown in same row...
on the above link we can see that 3 item(rows) are shown per row..
currently i'm using this code and using this single row are shown per row
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'enablePagination'=>false,
'columns'=>array(
'brand',
array(
'name'=>'model',
'header'=>'Model',
'type'=>'raw',
'value'=>'$data->model.($data->marketing_name?" (".$data->marketing_name.") ":"")'
),
array(
'name'=> 'platform',
'header'=>'Platform',
'type'=>'raw',
'value'=>'$data->platform->platform." ".$data->platform->platform_version'
),
array(
'name'=>'add',
'header'=>'Action',
'type'=>'html',
'value'=> 'CHtml::link("Add To My device", Yii::app()->createUrl("/site/add_device/id/".$data->id))',
)
),
));
?>
CGridView always displays each item in a separate row. For more flexibility (e.g. displaying three items side by side) you have to switch to using CListView instead, but this means you have to do more things yourself.
CListView has an itemView attribute that you have to set and uses the specified view to render each item in the list. Together with the template and itemsTagName attributes this lets you fully customize the HTML produced by your list.
To display three items per row you can use any general-purpose CSS technique such as giving each item display: inline-block and a fixed width of 1/3 of the container width; this will depend on how you want to achieve your layout.