Yii_wiki_204_using-cjuidialog-to-edit-rows-in-a-cgridview (

Source: Internet
Author: User

/*** 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 attacker http://blog.csdn.net/phpgcs Scenario Solution Column hyperlink Javascript function *** // *** background Scenario ***/me here there is a series of clients/events CGridView, for each line (eventClient), I want to implement a quick edit eventClient dialog box. My approach is based on this wiki http://www.yiiframework.com/wiki/145/cjuidialog-for-create-new-model//*** Solution ***/first after doing all the work based on wiki 145, then modify our CGridView: for each Column, Column hyperlink sets the _ updateComment_url attribute as the required url in the js function. 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 Functions include the updateComment () method that calls this action on the same page. <Script type = "text/javascript"> function updateComment () {// public property var _ updateComment_url; <? Php echo CHtml: ajax (array ('url' => 'js: updateComment. _ updateComment_url ', 'data' => "js: $ (this ). serialize () ", 'type' => 'post', 'ype ype '=> 'json', 'success' =>" function (data) {if (data. status = 'failed') {$ ('# dialogComment div.divcomment'cmd.html (data. div); // Here is the trick: on submit-> once again this function! $ ('# DialogComment div. divComment form '). submit (updateComment);} else {$ ('# dialogComment div.divcomment'cmd.html (data. div); setTimeout (\ "$ ('# dialogComment '). dialog ('close') \ ", 2000); // Refresh the grid with the update $. fn. yiiGridView. update ('event-client-grid') ;}} ",)?>; Return false ;}</script>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.