首頁 php教程 php手册 yii_wiki_204_using-cjuidialog-to-edit-rows-in-a-cgridview(通过CJuiDialog在CGridView中修改行数据)

yii_wiki_204_using-cjuidialog-to-edit-rows-in-a-cgridview(通过CJuiDialog在CGridView中修改行数据)

Jun 21, 2016 am 08:48 AM
gt quot

/*** 
Using CJuiDialog to edit rows in a CGridView   
 
http://www.yiiframework.com/wiki/204/using-cjuidialog-to-edit-rows-in-a-cgridview 
 
translated by php攻城师 
 
http://blog.csdn.net/phpgcs 
 
Scenario 
Solution 
Column hyperlink 
Javascript function 
 
**/  
  
/*** 
背景      Scenario 
***/   
  
我这里有一个 一系列的 clients/events 所属的 CGridView , 对每一行 (eventClient), 我想要实现快速的编辑 eventClient对话框。  
  
我的方法基于 这篇wiki http://www.yiiframework.com/wiki/145/cjuidialog-for-create-new-model/  
  
/*** 
 
解决方法  Solution  
 
***/  
  
首先基于 wiki 145 做了所有工作后, 再来 修改我们 的CGridView:  
  
Column hyperlink   
  
对每一列 , 在js 函数中设置 _updateComment_url 属性 为需要的 url。  
  
array(  
    'name'=>'comment',  
    'header'=>'Comments',  
    'type'=>'raw',  
    'value'=>'CHtml::link(  
        ($data["comment"]?$data["comment"]:"(comment)"),  
        "",  
        array(  
            \'style\'=>\'cursor: pointer; text-decoration: underline;\',  
            \'onclick\'=>\'{  
                updateComment._updateComment_url="\'.  
                    Yii::app()->createUrl(  
                        "eventClient/updateComment",  
                        array("id"=>$data["id"])  
                    )  
                .\'";  
                updateComment();  
                $("#dialogComment").dialog("open");}\'  
            )  
        );',  
),  
  
  
Javascript function   
  
在同一个页面我们将 调用这个 动作的 updateComment() 方法包含进来。   
  
<script type="text/javascript">  
   
function updateComment()  
{  
    // public property  
    var _updateComment_url;  
   
    <?php echo CHtml::ajax(array(  
        &#39;url&#39;=>&#39;js:updateComment._updateComment_url&#39;,  
        &#39;data&#39;=> "js:$(this).serialize()",  
        &#39;type&#39;=>&#39;post&#39;,  
        &#39;dataType&#39;=>&#39;json&#39;,  
        &#39;success&#39;=>"function(data)  
            {  
                if (data.status == &#39;failure&#39;)  
                {  
                    $(&#39;#dialogComment div.divComment&#39;).html(data.div);  
                    // Here is the trick: on submit-> once again this function!  
                    $(&#39;#dialogComment div.divComment form&#39;).submit(updateComment);  
                }  
                else  
                {  
                    $(&#39;#dialogComment div.divComment&#39;).html(data.div);  
                    setTimeout(\"$(&#39;#dialogComment&#39;).dialog(&#39;close&#39;) \",2000);  
   
                    // Refresh the grid with the update  
                    $.fn.yiiGridView.update(&#39;event-client-grid&#39;);  
                }  
   
        } ",  
    ))?>;  
    return false;  
   
}  
   
</script>  
登入後複製



本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前 By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

華為GT3 Pro和GT4的差異是什麼? 華為GT3 Pro和GT4的差異是什麼? Dec 29, 2023 pm 02:27 PM

華為GT3 Pro和GT4的差異是什麼?

修復:截圖工具在 Windows 11 中不起作用 修復:截圖工具在 Windows 11 中不起作用 Aug 24, 2023 am 09:48 AM

修復:截圖工具在 Windows 11 中不起作用

如何修復無法連線到iPhone上的App Store錯誤 如何修復無法連線到iPhone上的App Store錯誤 Jul 29, 2023 am 08:22 AM

如何修復無法連線到iPhone上的App Store錯誤

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决

watch4pro好還是gt好 watch4pro好還是gt好 Sep 26, 2023 pm 02:45 PM

watch4pro好還是gt好

如何使用 iPadOS 17.4 優化 iPad 電池壽命 如何使用 iPadOS 17.4 優化 iPad 電池壽命 Mar 21, 2024 pm 10:31 PM

如何使用 iPadOS 17.4 優化 iPad 電池壽命

管澤元江疏影體驗華為 MateBook GT 14:科技藝術完美結合 管澤元江疏影體驗華為 MateBook GT 14:科技藝術完美結合 Aug 10, 2024 pm 09:51 PM

管澤元江疏影體驗華為 MateBook GT 14:科技藝術完美結合

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没有关问题 不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没有关问题 Jun 13, 2016 am 10:15 AM

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没有关问题

See all articles