Rumah > pembangunan bahagian belakang > tutorial php > yii_wiki_204_using-cjuidialog-to-edit-rows-in-a-cgridview(通过_PHP教程

yii_wiki_204_using-cjuidialog-to-edit-rows-in-a-cgridview(通过_PHP教程

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Lepaskan: 2016-07-15 13:21:52
asal
1010 orang telah melayarinya

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

/***

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>

Salin selepas log masuk

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/477117.htmlTechArticle/*** 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/...
Label berkaitan:
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan