pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <small id='zlAtO'></small><noframes id='zlAtO'>

      <legend id='zlAtO'><style id='zlAtO'><dir id='zlAtO'><q id='zlAtO'></q></dir></style></legend>

        <bdo id='zlAtO'></bdo><ul id='zlAtO'></ul>
      <tfoot id='zlAtO'></tfoot>
      <i id='zlAtO'><tr id='zlAtO'><dt id='zlAtO'><q id='zlAtO'><span id='zlAtO'><b id='zlAtO'><form id='zlAtO'><ins id='zlAtO'></ins><ul id='zlAtO'></ul><sub id='zlAtO'></sub></form><legend id='zlAtO'></legend><bdo id='zlAtO'><pre id='zlAtO'><center id='zlAtO'></center></pre></bdo></b><th id='zlAtO'></th></span></q></dt></tr></i><div class="dbhfr7h" id='zlAtO'><tfoot id='zlAtO'></tfoot><dl id='zlAtO'><fieldset id='zlAtO'></fieldset></dl></div>

      GridView 行作為鏈接,Yii2 中的操作列項除外

      GridView row as link, except action column items in Yii2(GridView 行作為鏈接,Yii2 中的操作列項除外)

      <tfoot id='JnUnp'></tfoot>

          <tbody id='JnUnp'></tbody>

        <small id='JnUnp'></small><noframes id='JnUnp'>

              <bdo id='JnUnp'></bdo><ul id='JnUnp'></ul>
            • <i id='JnUnp'><tr id='JnUnp'><dt id='JnUnp'><q id='JnUnp'><span id='JnUnp'><b id='JnUnp'><form id='JnUnp'><ins id='JnUnp'></ins><ul id='JnUnp'></ul><sub id='JnUnp'></sub></form><legend id='JnUnp'></legend><bdo id='JnUnp'><pre id='JnUnp'><center id='JnUnp'></center></pre></bdo></b><th id='JnUnp'></th></span></q></dt></tr></i><div class="tlbzz7b" id='JnUnp'><tfoot id='JnUnp'></tfoot><dl id='JnUnp'><fieldset id='JnUnp'></fieldset></dl></div>
              <legend id='JnUnp'><style id='JnUnp'><dir id='JnUnp'><q id='JnUnp'></q></dir></style></legend>
              • 本文介紹了GridView 行作為鏈接,Yii2 中的操作列項除外的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                當我使用以下代碼時,它會覆蓋操作列刪除/更新鏈接.

                When i use the below code it overrides the action-column delete/update links.

                'rowOptions' => function ($model, $key, $index, $grid) {
                    return [
                        'id'      => $model['id'], 
                        'onclick' => 'location.href="' 
                            . Yii::$app->urlManager->createUrl('accountinfo/update') 
                            .'?id="+(this.id);',
                    ];
                },
                

                由于我有很多列,最好在一個地方指定鏈接 url,而不是在每一列中使用以下代碼:

                As I have many columns it would be good to specify link url in one place instead of using the below code in each column:

                 'value' => function ($data) {
                                return Html::url('site/index');
                            }
                

                那么有沒有什么最好的方法可以在 GridView 中為除操作列之外的整行提供鏈接?

                So is there any best way to give link for whole row in GridView except action column?

                完整的網格視圖

                GridView::widget([
                    'dataProvider' => $dataProvider,
                    'filterModel'  => $searchModel,
                    'rowOptions'   => function ($model, $index, $widget, $grid) {
                        if ($widget == 1)
                            return [
                                'id' => $model['id'], 
                                'onclick' => 'location.href="'
                                    . Yii::$app->urlManager->createUrl('accountinfo/update') 
                                    . '?id="+(this.id);'
                            ];
                    },
                    'columns'      => [
                        ['class' => 'yiigridSerialColumn'],
                
                        // 'id',
                        'f_name',
                        'l_name',
                        'address',
                        'country',
                        'state',
                        'city',
                        'pincode',
                        [
                            'attribute' => 'status',
                            'value'     => function ($model, $key, $index, $column) {
                                return $model->status == '1' ? 'Enabled' : 'Disabled';
                            },
                            'filter'    => [1 => 'Enabled', 0 => 'Disabled'],
                        ],
                        'card',
                        'note',
                        'balance',
                        'is_new',
                        [
                            'attribute' => 'is_new',
                            'value'     => function ($model, $key, $index, $column) {
                                return $model->is_new == '1' ? 'Yes' : 'No';
                            },
                            'filter'    => [1 => 'Yes', 0 => 'No'],
                        ],
                        [
                            'class'    => 'yiigridActionColumn',
                            'template' => '{update}&nbsp;&nbsp;{delete}',
                        ],
                    ],
                ]);
                

                推薦答案

                你可以試試這個.只要用戶單擊未被另一個元素覆蓋的 td 元素,它就會使整行可點擊.因此,操作列也是可點擊行的一部分,但不是字形.

                You could try this. It will make the whole row clickable as long as the user clicks on a td element that is not covered from another element. So also the action column is part of the clickable row, however, not the glyphicons.

                <?= GridView::widget([
                
                    ...
                
                    'rowOptions'   => function ($model, $key, $index, $grid) {
                        return ['data-id' => $model->id];
                    },
                
                    ...
                
                ]); ?>
                
                <?php
                $this->registerJs("
                
                    $('td').click(function (e) {
                        var id = $(this).closest('tr').data('id');
                        if(e.target == this)
                            location.href = '" . Url::to(['accountinfo/update']) . "?id=' + id;
                    });
                
                ");
                

                另請參閱 event.target 的文檔:

                目標屬性可以是為事件注冊的元素或它的后代.將 event.target 與這是為了確定事件是否因事件而被處理冒泡.這個屬性在事件委托中非常有用,當事件泡沫.

                The target property can be the element that registered for the event or a descendant of it. It is often useful to compare event.target to this in order to determine if the event is being handled due to event bubbling. This property is very useful in event delegation, when events bubble.

                這篇關于GridView 行作為鏈接,Yii2 中的操作列項除外的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                enable SOAP on PHP(在 PHP 上啟用 SOAP)
                Get received XML from PHP SOAP Server(從 PHP SOAP 服務器獲取接收到的 XML)
                not a valid AllXsd value(不是有效的 AllXsd 值)
                PHP SoapClient: SoapFault exception Could not connect to host(PHP SoapClient:SoapFault 異常無法連接到主機)
                Implementation of P_SHA1 algorithm in PHP(PHP中P_SHA1算法的實現)
                Sending a byte array from PHP to WCF(將字節數組從 PHP 發送到 WCF)
                  <tbody id='eRHt3'></tbody>
                <tfoot id='eRHt3'></tfoot>

                    <small id='eRHt3'></small><noframes id='eRHt3'>

                      • <legend id='eRHt3'><style id='eRHt3'><dir id='eRHt3'><q id='eRHt3'></q></dir></style></legend>
                        • <bdo id='eRHt3'></bdo><ul id='eRHt3'></ul>

                          <i id='eRHt3'><tr id='eRHt3'><dt id='eRHt3'><q id='eRHt3'><span id='eRHt3'><b id='eRHt3'><form id='eRHt3'><ins id='eRHt3'></ins><ul id='eRHt3'></ul><sub id='eRHt3'></sub></form><legend id='eRHt3'></legend><bdo id='eRHt3'><pre id='eRHt3'><center id='eRHt3'></center></pre></bdo></b><th id='eRHt3'></th></span></q></dt></tr></i><div class="b5hzpx7" id='eRHt3'><tfoot id='eRHt3'></tfoot><dl id='eRHt3'><fieldset id='eRHt3'></fieldset></dl></div>
                          主站蜘蛛池模板: 防水套管厂家_刚性防水套管_柔性防水套管_不锈钢防水套管-郑州中泰管道 | 磁力去毛刺机_去毛刺磁力抛光机_磁力光饰机_磁力滚抛机_精密金属零件去毛刺机厂家-冠古科技 | 实战IT培训机构_IT培训班选大学生IT技术培训中心_中公优就业 | 北京银联移动POS机办理_收银POS机_智能pos机_刷卡机_收银系统_个人POS机-谷骐科技【官网】 | 贵阳用友软件,贵州财务软件,贵阳ERP软件_贵州优智信息技术有限公司 | 北京亦庄厂房出租_经开区产业园招商信息平台 | 信阳网站建设专家-信阳时代网联-【信阳网站建设百度推广优质服务提供商】信阳网站建设|信阳网络公司|信阳网络营销推广 | 桨叶搅拌机_螺旋挤压/方盒旋切造粒机厂家-无锡市鸿诚输送机械有限公司 | 安驭邦官网-双向万能直角铣头,加工中心侧铣头,角度头[厂家直销] 闸阀_截止阀_止回阀「生产厂家」-上海卡比阀门有限公司 | 户外健身路径_小区健身器材_室外健身器材厂家_价格-浩然体育 | 全温恒温摇床-水浴气浴恒温摇床-光照恒温培养摇床-常州金坛精达仪器制造有限公司 | 广东佛电电器有限公司|防雷开关|故障电弧断路器|智能量测断路器 广东西屋电气有限公司-广东西屋电气有限公司 | 纯化水设备-EDI-制药-实验室-二级反渗透-高纯水|超纯水设备 | 实验室隔膜泵-无油防腐蚀隔膜泵-耐腐蚀隔膜真空泵-杭州景程仪器 电杆荷载挠度测试仪-电杆荷载位移-管桩测试仪-北京绿野创能机电设备有限公司 | 红立方品牌应急包/急救包加盟,小成本好项目代理_应急/消防/户外用品加盟_应急好项目加盟_新奇特项目招商 - 中红方宁(北京) 供应链有限公司 | 广州各区危化证办理_危险化学品经营许可证代办 | 十字轴_十字轴万向节_十字轴总成-南京万传机械有限公司 | 成都网站建设制作_高端网站设计公司「做网站送优化推广」 | 智成电子深圳tdk一级代理-提供TDK电容电感贴片蜂鸣器磁芯lambda电源代理经销,TDK代理商有哪些TDK一级代理商排名查询。-深圳tdk一级代理 | 焦作网 WWW.JZRB.COM| 菏泽知彼网络科技有限公司| 不锈钢拉手厂家|浴室门拉手厂家|江门市蓬江区金志翔五金制品有限公司 | 螺钉式热电偶_便携式温度传感器_压簧式热电偶|无锡联泰仪表有限公司|首页 | 蒸汽吸附分析仪-进口水分活度仪|康宝百科 | 蓝莓施肥机,智能施肥机,自动施肥机,水肥一体化项目,水肥一体机厂家,小型施肥机,圣大节水,滴灌施工方案,山东圣大节水科技有限公司官网17864474793 | 棉服定制/厂家/公司_棉袄订做/价格/费用-北京圣达信棉服 | 无硅导热垫片-碳纤维导热垫片-导热相变材料厂家-东莞市盛元新材料科技有限公司 | 学校用栓剂模,玻璃瓶轧盖钳,小型安瓿熔封机,实验室安瓿熔封机-长沙中亚制药设备有限公司 | 小程序开发公司_APP开发多少钱_软件开发定制_微信小程序制作_客户销售管理软件-济南小溪畅流网络科技有限公司 | 培训无忧网-教育培训咨询招生第三方平台 | 衬塑设备,衬四氟设备,衬氟设备-淄博鲲鹏防腐设备有限公司 | 时代北利离心机,实验室离心机,医用离心机,低速离心机DT5-2,美国SKC采样泵-上海京工实业有限公司 工业电炉,台车式电炉_厂家-淄博申华工业电炉有限公司 | 山东钢衬塑罐_管道_反应釜厂家-淄博富邦滚塑防腐设备科技有限公司 | 糖衣机,除尘式糖衣机,全自动糖衣机,泰州市长江制药机械有限公司 体感VRAR全息沉浸式3D投影多媒体展厅展会游戏互动-万展互动 | 尼龙PA610树脂,尼龙PA612树脂,尼龙PA1010树脂,透明尼龙-谷骐科技【官网】 | 安徽集装箱厂-合肥国彩钢结构板房工程有限公司 | 雪花制冰机(实验室雪花制冰机)百科 | 智慧钢琴-电钢琴-便携钢琴-数码钢琴-深圳市特伦斯乐器有限公司 | 日本东丽膜_反渗透膜_RO膜价格_超滤膜_纳滤膜-北京东丽阳光官网 日本细胞免疫疗法_肿瘤免疫治疗_NK细胞疗法 - 免疫密码 | 净水器代理,净水器招商,净水器加盟-FineSky德国法兹全屋净水 | 阴离子聚丙烯酰胺价格_PAM_高分子聚丙烯酰胺厂家-河南泰航净水材料有限公司 |