yii2从ListView中删除摘要/计数

时间:2015-03-06 22:53:45

标签: php listview yii2

当我使用ListView时,我总是会计算。例如说:

Showing 1-1 of 1 item.

我的结果/项目在上面。我该如何删除?

当前ListView代码

<?=  ListView::widget([
        'dataProvider' => $dataProvider,
        'itemOptions' => ['class' => 'col-xs-6 col-sm-3'],
        'itemView' => '_index',]);
    ?>

5 个答案:

答案 0 :(得分:23)

发现我的回答使用了以下行:

'summary'=>'', 

答案 1 :(得分:2)

添加'summary'=&gt; ''如下面的html页面:

<?php

echo GridView::widget([
    'dataProvider' => $model,
    'summary' => "",
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],
        [
            'attribute' => 'name',
            'value' => function ($model) {
                return (!empty($model->name) && !empty($model->name) ) ? $model->name : 'NA';
            }
        ],
        [
            'attribute' => 'status',
            'format' => 'raw',
            'value' => function ($model) {
                return $model->getStatus();
            }
        ]
    ],
]);
?>

答案 2 :(得分:2)

在列表视图中使用&#39;摘要&#39; =&gt;&#39;&#39;

语法:

<?= ListView::widget([
        'dataProvider' => $dataProvider,
        'itemOptions' => ['class' => 'item'],
        'itemView' => '_step',
    'summary'=>''

    ]) ?>

答案 3 :(得分:1)

您也可以使用emptyText来显示自定义消息

<?= ListView::widget([
  'dataProvider' => $dataProviderTodos,
  'pager' => [
  ],
  'options' => [
    'tag' => 'div',
    'id' => 'case-notes-wrapper',
    'class' => 'case-notes-wrapper'
  ],
  'layout' => "{items}\n{pager}",
  'itemView' => '',
  'emptyText' => '',
]); ?>

如需了解更多信息,请click

答案 4 :(得分:0)

您还可以使用:

    <template>
  <v-dialog
    persistent
    v-model="dialog"
    width="600"
  >
    <template v-slot:activator="{ on }">
      <v-btn depressed color="primary" v-on="on">
        <v-icon class="pr-2">check</v-icon>Approve
      </v-btn>
    </template>
    <v-card>
      <div class="px-4 pt-3">
        <span class="subheading font-weight-bold">Approve Details</span>
        <input
          ref="image"
          type="file"
          name="image"
          accept="image/*"
          style="display: none;"
          @change="setImage"
        />
        <v-layout row wrap align-center>
          <v-flex xs12 class="pa-0">
            <div class="text-xs-center">
              <v-img :src="imgUrl" contain/>
            </div>
            <VueCropper
              :dragMode="'none'"
              :viewMode="1"
              :autoCrop="false"
              :zoomOnWheel="false"
              :background="false"
              :src="imgSrc"
              v-show="false"
              ref="cropper"
            />
            <v-form ref="addImageForm" lazy-validation>
              <v-layout row wrap class="pt-2">
                <v-flex xs12>
                  <v-text-field
                    outline
                    readonly
                    :label="imgSrc ? 'Click here to change the image' : 'Click here to upload image'"
                    append-icon='attach_file'
                    :rules="imageRule"
                    v-model='fileName'
                    @click='launchFilePicker'
                  ></v-text-field>
                </v-flex>
              </v-layout>
            </v-form>
          </v-flex>
        </v-layout>
      </div>
      <v-divider></v-divider>
      <v-card-actions class="px-4">
        <v-btn
          large
          flat
          @click="resetImage()"
        >Cancel</v-btn>
        <v-spacer></v-spacer>
        <v-btn
          large
          depressed
          color="primary"
          @click="approveCashout"
          :loading="isUploading"
        >Approve</v-btn>
      </v-card-actions>
    </v-card>
  </v-dialog>
</template>

我更喜欢'summary'=> false 而不是空字符串,以提高可读性。