當前位置: 首頁>>代碼示例>>PHP>>正文


PHP widgets\ListView類代碼示例

本文整理匯總了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);
 }
開發者ID:manyoubaby123,項目名稱:imshop,代碼行數:11,代碼來源:ListView.php

示例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;
 }
開發者ID:nhatvuvan,項目名稱:yii2-widgets,代碼行數:39,代碼來源:MetaInfo.php

示例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;
    }
開發者ID:nhatvuvan,項目名稱:yii2-widgets,代碼行數:29,代碼來源:ParentList.php

示例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});");
 }
開發者ID:roman444uk,項目名稱:yii2,代碼行數:11,代碼來源:ListView.php

示例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&amp;sort=customer_id" data-sort="customer_id">Customer</a>') !== false);
     $this->assertTrue(strpos($actualHtml, '<a href="/index.php?r=site%2Findex&amp;sort=total" data-sort="total">Invoice Total</a>') !== false);
 }
開發者ID:howq,項目名稱:yii2,代碼行數:9,代碼來源:LinkSorterTest.php

示例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();
 }
開發者ID:simplator,項目名稱:base,代碼行數:13,代碼來源:SortableListView.php

示例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(); }"]]);
 }
開發者ID:pafnow,項目名稱:yii2-widgets,代碼行數:10,代碼來源:GpGallery.php

示例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">
開發者ID:giicms,項目名稱:tour,代碼行數:31,代碼來源:index.php

示例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>
開發者ID:gouchaoer,項目名稱:yii2-starter-kit,代碼行數:15,代碼來源:index.php

示例10: init

 public function init()
 {
     parent::init();
     $this->options['class'] .= ' row component component-resource-list';
     $this->itemOptions['tag'] = false;
     $this->summary = false;
 }
開發者ID:luhaoz,項目名稱:mcwiki,代碼行數:7,代碼來源:ResourceList.php

示例11: renderPager

 /**
  * @inheritdoc
  */
 public function renderPager()
 {
     if ($this->dataProvider->getPagination()->pageSize == 0) {
         return '';
     }
     return parent::renderPager();
 }
開發者ID:frostiks25,項目名稱:rzwebsys7,代碼行數:10,代碼來源:ListView.php

示例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);
 }
開發者ID:mg-code,項目名稱:yii2-infinite-list-view,代碼行數:13,代碼來源:ListView.php

示例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);
 }
開發者ID:amnah,項目名稱:yii2-classes,代碼行數:12,代碼來源:ExtListView.php

示例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();
 }
開發者ID:elitedivision,項目名稱:amos-core,代碼行數:9,代碼來源:MapView.php

示例15: renderSection

 /**
  * @inheritdoc
  */
 public function renderSection($name)
 {
     switch ($name) {
         case "{pagesizer}":
             return $this->renderPagesizer();
         default:
             return parent::renderSection($name);
     }
 }
開發者ID:nkovacs,項目名稱:yii2-pagesizer,代碼行數:12,代碼來源:ListView.php


注:本文中的yii\widgets\ListView類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。