如何使用Yahoo YUI进行写入数据库的内联单元格编辑?

时间:2011-10-07 18:02:10

标签: javascript yui yahoo

所以我使用YUI 2.0进行数据表设置。对于我的一个列定义,我已将其设置为当您单击一个单元格时,弹出一组单选按钮选项,以便您可以修改该单元格内容。

我希望所做的任何更改都能反映在数据库中。所以我订阅了radioClickEvent。这是我的代码:

Ex.myDataTable.subscribe(“radioClickEvent”,function(oArgs){

                    // hold the change for now
                    YAHOO.util.Event.preventDefault(oArgs.event);
                    // block the user from doing anything
                    this.disable();

                    // Read all we need
                    var elCheckbox = oArgs.target,
                        newValue = elCheckbox.checked,
                        record = this.getRecord(elCheckbox),
                        column = this.getColumn(elCheckbox),
                        oldValue = record.getData(column.key),
                        recordIndex = this.getRecordIndex(record),
                        session_code = record.getData(\'session_code\');
                    alert(newValue);

                    // check against server
                    YAHOO.util.Connect.asyncRequest(
                        "GET",
                        "inlineeddit.php?sesscode=session_code&", 
                        {
                            success:function(o) {
                                alert("good");
                                var r = YAHOO.lang.JSON.parse(o.responseText);
                                if (r.replyCode == 200) {
                                    // If Ok, do the change
                                    var data = record.getData();
                                    data[column.key] = newValue;
                                    this.updateRow(recordIndex,data);
                                } else {
                                    alert(r.replyText);
                                }
                                // unblock the interface
                                this.undisable();
                            },
                            failure:function(o) {
                                alert("bad");
                                //alert(o.statusText);
                                this.undisable();
                            },
                            scope:this
                        }

                    );                                              
                });

    Ex.myDataTable.subscribe("cellClickEvent", Ex.myDataTable.onEventShowCellEditor);    

但是,当我运行我的代码并单击一个单元格并单击一个单选按钮时,没有任何事情发生。我已经看了一段时间,我不知道我做错了什么。我知道你也可以在我的列定义中使用asyncsubmitter我相信并尝试过,但这对我来说也不适用。

任何想法都将不胜感激。

0 个答案:

没有答案