开发者

How do I use the Yahoo YUI to do inline cell editing that writes to a database?

开发者 https://www.devze.com 2023-04-11 06:41 出处:网络
So I have datatable setup using the YUI 2.0.And for one of my column definitions, I\'ve set it up so when you click on a cell, a set of radio button options pops so you can modify that cell content.

So I have datatable setup using the YUI 2.0. And for one of my column definitions, I've set it up so when you click on a cell, a set of radio button options pops so you can modify that cell content.

I want whatever changes are made to be reflected in the database. So I subscribe to a radioClickEvent. Here is开发者_Go百科 my code for that:

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);    

But when I run my code and I click on a cell and I click a radio button, nothing happens ever. I've been looking at this for some time and I have no idea what I'm doing wrong. I know you can also use asyncsubmitter within my column definition I believe and I tried that, but that also wasn't working for me.

Any ideas would be greatly appreciated.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号