• 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代码注册到页面底部 ?>
  • 相关阅读:
    清华同方 峰锐 K469 不开机维修
    开发一个简单实用的 本地音乐播放器
    DELL XPS l502x 触控板修修 主板进水
    Unreal Engine:变量同步
    UE4:网络同步
    UE4:专属服务器实例
    Java(11)_字节缓冲流&字符流
    Java(12)_IO流&Properties集合
    2022年4月16日12点06分
    HY57V641620ETH和HY57V641620FTP7的区别
  • 原文地址:https://www.cnblogs.com/benlightning/p/5227157.html
Copyright © 2020-2023  润新知