I am trying to modify a table built using Yii boostrap and CactiveDataprovider, the table works fine but it automatically also displays the count of all items found, how to disable displaying this count
this is the view logic currently
$this->widget('bootstrap.widgets.TbListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'viewData'=>array('page'=>$page),
'itemsTagName'=>'table',
'itemsCssClass'=>'items table table-striped table-condensed',
'emptyText'=>'<i> Sorry, there are no active items to display</i>',
));
You need to add this line:
'template' => "{sorter}\n{items}\n{pager}",
TbListView extends from CListView, which uses the template variable to control the layout. See: http://www.yiiframework.com/doc/api/1.1/CListView#template-detail
The default template is "{summary}\n{sorter}\n{items}\n{pager}" where {summary} is what shows the count. So if you remove that, the count won't show
You might be reffering to: example
If so, set the template property as needed.
You need to delete the summary text.
pages stands for the pagination
items stands for ... the list of items
<?php
$this->widget('zii.widgets.CListView', array(
'dataProvider' => $dataProvider,
'template' => "{summary}\n{pager}\n{items}\n{summary}\n{pager}",
'itemView' => '_index',
'pager' => array(
'maxButtonCount' => 10,
),
)
);
?>
It is easy.
put propriety summaryText false.
<?php $this->widget('bootstrap.widgets.TbListView',array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view_mercado',
'summaryText'=>false //make it for hide summary text
)); ?>
What about using CSS? is pretty straight forward
I got this alternative answer from an offline source, posting here for completeness.Both Ionut-flavius-Pogacian and frostyterrier methods worked and are better solutions as defining the template gives even more control over the widget behavior rather than just defining the summaryText as in the answer below
Tblistview is not documented in Yii-bootstrap documentation, but scanning the source it seems it is wrapper for CListview class in Yii.
CListview extends CBaseListView which has the summaryText property. Passing Blank data to it, removes the count which is active by default.
http://www.yiiframework.com/doc/api/1.1/CBaseListView#template-detail
SummaryText has the following usable variables
{start}: the starting row number (1-based) currently being displayed
{end}: the ending row number (1-based) currently being displayed
{count}: the total number of rows
{page}: the page number (1-based) current being displayed, available since version 1.1.3
{pages}: the total number of pages, available since version 1.1.3
{start} {end} and {count} are visible by default
The code could be modified to
$this->widget('bootstrap.widgets.TbListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'viewData'=>array('page'=>$page),
'itemsTagName'=>'table',
'itemsCssClass'=>'items table table-striped table-condensed',
'emptyText'=>'<i> Sorry, there are no active items to display</i>',
'summaryText'=>''
));
Related
I have a CGridView, one particular column is CLinkColumn. The footer for this column presently appears in plain text, I need it to be hyperlinked as well.
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$provider_sales,
'columns'=>array(
...,
array(
'header'=>'Status',
'class'=>'CLinkColumn',
'urlExpression'=>function($data){ return ...},
'footer'=> number_format($totals['status']),
),
),
));
How do I convert it to a hyperlink?
Now I just need one footer item to hyperlink, this could change tomorrow.
Hi You can simply use this CHtml::link in footer
'footer'=> CHtml::link(number_format($totals['status']),Yii::app()->createUrl("Your_Url"),array("target"=>"_blank")),
You can also pass param in this
CHtml::link('Link Text',array('controller/action',
'param1'=>'value1'));
For more info please read http://www.yiiframework.com/wiki/48/by-example-chtml/#hh0
I use CGridView in Yii to create tables. I would like to show my table with pagination, but display summary text (i.e. Displaying 1-4 of 4 results.) at the bottom of grid. Is it possible in Yii?
You need to add this property to your array options widget:
'template'=>'{items}{summary}{pager}'
This is how it should look like:
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$model->search(),
'filter'=>$model,
'enablePagination' => true,
'template'=>'{items}{summary}{pager}',
'columns'=>array(...)
),
));
Yii docs - CBaseListView
'template'=>"{summary}\n{items}\n{pager}"
I want to apply a different style for last entity of CListView , I noticed that there is a property "lastItemCssClass" for CMenu but this property does not exist for CListView. Someone would have an idea how to do this?
<?php
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemsTagName'=>'ul',
'summaryText' => '',
'enablePagination'=>false,
'itemView'=>'_viewItem',
));
?>
Without having more HTML and CSS available you may want to consider the last-child pseudo selector, refined around whatever your PHP's output HTML is.
When I use my CListView Widget in a page the fontsize of my whole website changes. I use flowtype to scale my fonts and keep everything responsive. Only when I use this widget everything changes, nog only the data of the widget itself.
I tried to turn the css styling of the widget of and tried to control it via an own css file, but this doesn't matter.
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'cssFile'=>false,
)); ?>
The content of the view I'm calling doesn't matter either. Only when I remove the widget and put some text instead it changes back to normal.
Does someone have any idea what's happening here?
Quoted from official documentation for ClistView
cssFile property
public string $cssFile;
the URL of the CSS file used by this list view. Defaults to null,
meaning using the integrated CSS file. If this is set false, you are
responsible to explicitly include the necessary CSS file in your page.
Follow it, when you used CListView, default css .../listview/style.css file would be imported into your page, it could change your current layout if some of css is coincided with each other.
You can override it
$this->widget('zii.widgets.CListView', array(
'cssFile' => 'your-css-file-path.css',
...
)
So, eventually tried to copy the parsed code from the page source into my view. So in pagecode this was exactly the same output as the widget does in the page. Now I didn't had the resizing problem. So the widgets do something more then I can see.
For the solution I wrote an own widget to get my data in which I can control everything that happens. So no problem left anymore. Thanks for your help Telvin!
I want to display a loading image when I click on a sorting link of a listing record. Before, I used the complete property of Paginator. This works well if the table has more than one record.
My code is as follows:
<?php
$this->Paginator->options(array(
'update' => '#ourCompany-part',
'evalScripts' => true,
'before' => $this->Js->get('#loading')->
effect('fadeIn', array('buffer' => false)),
'complete' => $this->Js->get('#loading')->
effect('fadeOut', array('buffer' => false)),
));
?>
When the table has one record and we click on the sorting link of the paginator, it doesn't display the loading image. If the table has no records, then the index page is not loaded. How could I solve this?
Personally i don't like JsHelper i wrote jquery pugins or small function in my view. So check that the javascript looks like where you see 1 record or no record, it seems that helper not render javascitpt.