yii_wiki_204_using-cjuidialog-to-edit-rows-in-a-cgridview(通过CJuiDialog在CGridView中修改行数据)
2013-09-11 20:14
459 查看
/*** 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( 'url'=>'js:updateComment._updateComment_url', 'data'=> "js:$(this).serialize()", 'type'=>'post', 'dataType'=>'json', 'success'=>"function(data) { if (data.status == 'failure') { $('#dialogComment div.divComment').html(data.div); // Here is the trick: on submit-> once again this function! $('#dialogComment div.divComment form').submit(updateComment); } else { $('#dialogComment div.divComment').html(data.div); setTimeout(\"$('#dialogComment').dialog('close') \",2000); // Refresh the grid with the update $.fn.yiiGridView.update('event-client-grid'); } } ", ))?>; return false; } </script>
相关文章推荐
- yii_wiki_204_using-cjuidialog-to-edit-rows-in-a-cgridview(通过CJuiDialog在CGridView中修改行数据)
- yii_wiki_216_update-delete-model-with-cjuidialog-works-in-cgridview(通过CJuiDialog在CGridView中CRUD)
- yii_wiki_145_yii-cjuidialog-for-create-new-model (通过CJuiDialog来创建新的Model)
- yii_wiki_145_yii-cjuidialog-for-create-new-model (通过CJuiDialog来创建新的Model)
- CGridView: Update/create records in a CJuiDialog
- Yii 1.1: Using CButtonColumn to customize buttons in CGridView Follow @yiiframework
- Yii弹出窗口组件CJuiDialog
- Yii弹出窗口组件CJuiDialog
- Using Dialog Templates to create an InputBox() in C++
- Yii弹出窗口组件CJuiDialog
- how to display a loading gif when using jquery ui dialog iframe
- Yii CJuiDialog显示一个对话框部件
- Yii: 如何在CGridView通过Ajax方式刷新数据后执行JS脚本
- How to use toolbar control on dialog using CToolBar class in VC++ - VC++ 中用CToolBar 类如何使用ToolBar控件
- YII CJuiDialog 中运行ajax CGridView
- How to change pager CSS in CGridView CListView in Yii
- How to create an XTR file from XML in Delphi XE4 using XML Mapper?(delphi中如何通过xmlmapper创建xtr文件)
- Yii框架弹出窗口组件CJuiDialog用法分析
- 使用cocapods报错 [!] Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes
- How to make awesome UI components in iOS 8 using Swift and XCode 6