本文整理汇总了PHP中yii\widgets\ListView类的典型用法代码示例。如果您正苦于以下问题:PHP ListView类的具体用法?PHP ListView怎么用?PHP ListView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ListView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @inheritdoc
*/
public function run()
{
parent::run();
$id = $this->options['id'];
ListViewAsset::register($this->getView());
$this->registerClientOptions($id);
$this->registerClientEvents($id);
}
示例2: run
public function run()
{
$ret_val = '';
if (isset($this->header) && is_string($this->header) && !is_bool($this->header)) {
$ret_val = Html::tag('h2', $this->header);
}
switch ($this->displayAs) {
case 'grid':
$this->items = is_array($this->items) ? $this->items : [$this->items];
$this->widgetOptions = array_merge(['summary' => false, 'layout' => '{items}', 'showHeader' => $this->header, 'dataProvider' => new \yii\data\ArrayDataProvider(['allModels' => $this->items]), 'columns' => $this->attributes], $this->widgetOptions);
$ret_val .= \kartik\grid\GridView::widget($this->widgetOptions);
break;
case 'list':
$this->widgetOptions = array_merge(['itemOptions' => ['tag' => false], 'summary' => false, 'dataProvider' => new \yii\data\ArrayDataProvider(['allModels' => $this->items]), 'itemView' => function ($model, $key, $index, $widget) {
return $this->renderListItem($model, $key, $index, $widget);
}], $this->widgetOptions);
$ret_val .= \yii\widgets\ListView::widget($this->widgetOptions);
break;
case 'csv':
$ret_val = [];
foreach ($this->items as $index => $item) {
$ret_val[] = $this->renderCsvItem($item, $index);
}
$ret_val = Html::tag('div', implode(', ', $ret_val));
break;
case 'tags':
foreach ($this->items as $index => $item) {
$ret_val .= $this->renderTagItem($item, $index);
}
$ret_val = Html::tag('div', $ret_val);
break;
default:
$this->widgetOptions['class'] = isset($this->widgetOptions['class']) ? $this->widgetOptions['class'] : 'table';
$this->widgetOptions = array_merge(['model' => $this->items, 'attributes' => $this->attributes, 'options' => ['class' => 'table']], $this->widgetOptions);
$ret_val .= \yii\widgets\DetailView::widget($this->widgetOptions);
break;
}
return $ret_val;
}
示例3: run
public function run()
{
$header = Html::tag(ArrayHelper::remove($this->labelOptions, 'tag', 'h4'), 'Parents', $this->labelOptions);
if (count($this->labelContainerOptions)) {
$header = Html::tag(ArrayHelper::remove($this->labelContainerOptions, 'tag', 'div'), $header, $this->labelContainerOptions);
}
$list = ListView::widget(['summary' => false, 'emptyText' => Html::tag('ul', '', $this->options), 'options' => $this->options, 'itemOptions' => $this->itemOptions, 'dataProvider' => $this->dataProvider, 'itemView' => function ($model, $key, $index, $widget) {
return $model->name . (!$this->viewOnly ? Html::tag('span', Html::a("Remove " . Icon::show('remove'), '/' . $this->model->isWhat() . "/remove-parent/" . $this->model->getId() . '/' . $model['id'], ['role' => 'parentListItem', 'style' => 'color:white']), ['class' => 'badge']) : '');
}]);
if (count($this->listOptions)) {
$list = Html::tag(ArrayHelper::remove($this->listOptions, 'tag', 'div'), $list, $this->listOptions);
}
if (!$this->viewOnly) {
$script = Html::tag('script', new \yii\web\jsExpression('$(document).ready(function () {
$("#' . $this->options['id'] . '").find(\'[role="parentListItem"]\').each(function () {
$(this).on("click", function (event) {
event.preventDefault();
var $element = $(this);
$.post(this.href, function (result) {
if(result) $element.parents("li").remove();
});
});
});
})'), ['type' => 'text/javascript']);
} else {
$script = '';
}
return Html::tag('div', $header . $list, $this->containerOptions) . $script;
}
示例4: run
/**
* Runs the widget.
*/
public function run()
{
parent::run();
$options = Json::htmlEncode($this->getClientOptions());
$view = $this->getView();
ListViewAsset::register($view);
$view->registerJs("jQuery('#{$this->id}').yiiListView({$options});");
}
示例5: testLabelsExplicit
public function testLabelsExplicit()
{
$dataProvider = new ActiveDataProvider(['query' => Order::find(), 'models' => [new Order()], 'totalCount' => 1, 'sort' => ['attributes' => ['total'], 'route' => 'site/index']]);
ob_start();
echo ListView::widget(['dataProvider' => $dataProvider, 'layout' => "{sorter}"]);
$actualHtml = ob_get_clean();
$this->assertFalse(strpos($actualHtml, '<a href="/index.php?r=site%2Findex&sort=customer_id" data-sort="customer_id">Customer</a>') !== false);
$this->assertTrue(strpos($actualHtml, '<a href="/index.php?r=site%2Findex&sort=total" data-sort="total">Invoice Total</a>') !== false);
}
示例6: run
/**
* Runs the widget.
*/
public function run()
{
$id = $this->options['id'];
$view = $this->getView();
$options = Json::encode(['options' => $this->clientOptions, 'encode' => $this->encode, 'action' => $this->action, 'method' => $this->method]);
JuiAsset::register($this->getView());
SortableListViewAsset::register($view);
$view->registerJs("jQuery('#{$id}').sortableListView({$options});");
parent::run();
}
示例7: run
public function run()
{
$this->view->registerJs('function refreshGpGallery() {
$(".gpgallery").collagePlus({"targetHeight": 250, "allowPartialLastRow": true, "childrenFilterSelector": ".inline"});
$(".gpgallery").collageCaption({"images": $(".inline:not(:has(div))")});
}
$(window).load(function() { refreshGpGallery(); });
$(window).resize(function() { refreshGpGallery(); });');
echo ListView::widget(['dataProvider' => $this->dataProvider, 'itemOptions' => ['tag' => false], 'itemView' => $this->itemView, 'layout' => "<div class=\"gpgallery\">{items}</div>\n{pager}", 'pager' => ['class' => \kop\y2sp\ScrollPager::className(), 'triggerOffset' => 999999, 'noneLeftText' => 'No more item to display', 'noneLeftTemplate' => '<div class="clearfix"></div><div class="ias-noneleft" style="text-align: center;"><small class="text-muted">{text}</small>', 'enabledExtensions' => [\kop\y2sp\ScrollPager::EXTENSION_TRIGGER, \kop\y2sp\ScrollPager::EXTENSION_SPINNER, \kop\y2sp\ScrollPager::EXTENSION_NONE_LEFT], 'eventOnRendered' => "function() { refreshGpGallery(); }"]]);
}
示例8:
<?php
$path = Yii::$app->urlManager->createAbsoluteUrl('/webroot/');
use giicms\forum\components\widgets\CategoryWidget;
use yii\widgets\ListView;
?>
<section class="content">
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-8">
<!-- POST -->
<?php
echo ListView::widget(['dataProvider' => $dataProvider, 'options' => ['tag' => 'div'], 'layout' => "{pager}\n{items}\n{summary}", 'itemView' => '_post']);
?>
<!-- POST -->
</div>
<div class="col-lg-4 col-md-4">
<!-- -->
<!-- -->
<div class="sidebarblock">
<h3>Poll of the Week</h3>
<div class="divline"></div>
<div class="blocktxt">
<p>Which game you are playing this week?</p>
<form action="http://forum.azyrusthemes.com/index.html#" method="post" class="form">
示例9:
<?php
/* @var $this yii\web\View */
$this->title = Yii::t('frontend', 'Articles');
echo $this->render('_typehead');
?>
<div id="article-index">
<h1><?php
echo Yii::t('frontend', 'Articles');
?>
</h1>
<?php
echo \yii\widgets\ListView::widget(['dataProvider' => $dataProvider, 'pager' => ['hideOnSinglePage' => true], 'itemView' => '_item']);
?>
</div>
示例10: init
public function init()
{
parent::init();
$this->options['class'] .= ' row component component-resource-list';
$this->itemOptions['tag'] = false;
$this->summary = false;
}
示例11: renderPager
/**
* @inheritdoc
*/
public function renderPager()
{
if ($this->dataProvider->getPagination()->pageSize == 0) {
return '';
}
return parent::renderPager();
}
示例12: renderSection
/**
* Renders a section of the specified name.
* If the named section is not supported, false will be returned.
* @param string $name the section name, e.g., `{summary}`, `{items}`.
* @return string|boolean the rendering result of the section, or false if the named section is not supported.
*/
public function renderSection($name)
{
if ($name == '{pagerTop}') {
return $this->renderPagerTop();
}
return parent::renderSection($name);
}
示例13: renderEmpty
/**
* @inheritdoc
*/
public function renderEmpty()
{
// run normal parent implementation if view is not set
if (empty($this->emptyView)) {
return parent::renderEmpty();
}
// render closure/view
return $this->emptyView instanceof Closure ? call_user_func($this->emptyView) : $this->getView()->render($this->emptyView, $this->emptyViewParams);
}
示例14: init
public function init()
{
parent::init();
$LatLngCenter = new LatLng(['lat' => $this->centerPoint['lat'], 'lng' => $this->centerPoint['lng']]);
$this->map = new Map(['zoom' => $this->zoom, 'center' => $LatLngCenter, 'width' => '100%']);
$this->initMarkers();
$this->pushMarkers();
$this->flushMap();
}
示例15: renderSection
/**
* @inheritdoc
*/
public function renderSection($name)
{
switch ($name) {
case "{pagesizer}":
return $this->renderPagesizer();
default:
return parent::renderSection($name);
}
}