zoukankan      html  css  js  c++  java
  • yii2 pjax使用

    Pjax::begin(['id'=>'datalist']);
    echo GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => yiigridCheckboxColumn::className()],
            'id',
            [
                'header' => '姓名',
                'label' => '姓名',
                'attribute' => 'name'
            ],
            [
                'header' => '职位',
                'label' => '职位',
                'attribute' => 'position'
            ],
            [
                'header' => '手机',
                'label' => '手机',
                'attribute' => 'mobile'
            ],
            [
                'header' => '状态',
                'label' => '状态',
                'attribute' => 'status',
                'value' => function($data) {
                    return appmodelsuser::getStatus()[$data->status];
                }
            ],
            [
                'header' => '操作',
                'class' => 'yiigridActionColumn',
            ],
        ],
        'layout' => "{items}
    {summary}
    <div style="text-align:center;">{pager}</div>",
        'summary' => false,
            //'summaryOptions'=>['class' => 'summary'],
    ]);
    Pjax::end();
    

      其他的一些链接需要使用pjax时这么用(不能使用js的跳转,支持a标签,和form):

    <?php $this->beginBlock('pagejs'); ?>
        $(function () {
            /*search start*/
            $('.usico-search').on('click', function () {
                var name = $.trim($('.search').val());
                if (name) {
                    //window.location.href = '<?= Url::to(['/oamanager']) ?>?name=' + name;
                } else {
                    $('.search').focus();
                    return false;
                }
            });
            /*search end*/
            
            jQuery(document).pjax("button a[link-pjax]", "#datalist", {"push":true,"replace":false,"timeout":1000,"scrollTo":false});
            jQuery(document).on('submit', "form[data-pjax]", function (event) {jQuery.pjax.submit(event, '#datalist', {"push":true,"replace":false,"timeout":1000,"scrollTo":false});});
    $.pjax.reload('#datalist'); });
    <?php $this->endBlock(); ?> <?php $this->registerJs($this->blocks['pagejs'], yiiwebView::POS_END); //将编写的js代码注册到页面底部 ?>
  • 相关阅读:
    解决Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4
    spring task:annotation-driven 定时任务
    Windows注意目录
    vbScript 备忘
    java 将字符串数组变为字典顺序排序后的字符串数组
    jquery选中以什么开头的元素
    java如何将毫秒数转为相应的年月日格式
    jstl foreach 取index
    jQuery 效果
    js判断一个字符串是以某个字符串开头
  • 原文地址:https://www.cnblogs.com/benlightning/p/5227157.html
Copyright © 2011-2022 走看看