YUI datable客户端使用HTML下拉列表过滤数据

时间:2011-11-05 19:07:10

标签: yui

我正在使用YUI数据客户端过滤数据与HTML下拉(选项是AAA,BBB,CCC)。当我第一次使用gAllReminderCallsArray加载YUI数据表但是当我使用更新的gAllReminderCallsArray重新加载YUI数据表并且在下拉列表中选择了相同的值时,它根本不进行过滤,因此在我更改/选择下拉选项(示例AAA)时过滤正确AAA)。

YAHOO.example.ReminderCallsTable = function() 
                {               
                    MyDataSource = new YAHOO.util.DataSource(gAllReminderCallsArray,{
                        responseType : YAHOO.util.DataSource.TYPE_JSARRAY,
                        responseSchema : {fields : ["OpportunityID","button","ReminderCallOutcome","SchedulingAssistant"]}
                        ,doBeforeCallback : function (req,raw,res,cb) {
                            // This is the filter function
                            var data = res.results || [],
                            filtered = [],
                            i,l;

                            if (req) {
                            req = req.toLowerCase();
                            for (i = 0, l = data.length; i < l; ++i) {
                                if (!data[i].SchedulingAssistant.toLowerCase().indexOf(req)) {
                                    filtered.push(data[i]);
                                }
                            }
                            res.results = filtered;
                            }

                            return res;
                        }
                    });

                    var MyColumnDefs = [            
                        {key:"OpportunityID", label: "Opportunity ID"},                                                                                  
                        {key:"button", label:"Update/Show", formatter:YAHOO.widget.DataTable.formatButton}, 
                        {key:"ReminderCallOutcome", label: "Outcome",sortable:true,formatter:YAHOO.widget.DataTable.formatImage},  
                        {key:"SchedulingAssistant", label: "CSR",sortable:true}
                        ];  

                    var MyConfigs = {paginator : new YAHOO.widget.Paginator({rowsPerPage: 20})};                            
                    var MyDataTable = new YAHOO.widget.DataTable("ReminderCallsTable", MyColumnDefs, MyDataSource,MyConfigs); 

                    filterTimeout = null;
                    updateFilter  = function () {
                        // Reset timeout
                        filterTimeout = null;                           

                        // Get filtered data
                        MyDataSource.sendRequest(YAHOO.util.Dom.get('ServiceCoordinator').value,{
                        success : MyDataTable.onDataReturnInitializeTable,
                        failure : MyDataTable.onDataReturnInitializeTable,
                        scope   : MyDataTable,
                        argument: state
                        });
                    };

                    YAHOO.util.Event.on('ServiceCoordinator','change',function (e) {                       
                        clearTimeout(filterTimeout);
                        setTimeout(updateFilter,600);
                    });                                       

                    MyDataTable.subscribe("rowMouseoverEvent", MyDataTable.onEventHighlightRow); 
                    MyDataTable.subscribe("rowMouseoutEvent", MyDataTable.onEventUnhighlightRow); 
                    MyDataTable.subscribe("rowClickEvent",MyDataTable.onEventSelectRow);                        
                    gAllRecords = MyDataTable;                              

                    MyDataTable.subscribe("buttonClickEvent", function(oArgs){                   
                    var oRecord = this.getRecord(oArgs.target);                             
                    gSelectedObjectID = oRecord.getData('EventID');                                                     
                    var CurrentInfo = oRecord.getData("ClaimantName") + " - " +  oRecord.getData("Type");               
                    SelectedReminderCallCurrentOutcome(gSelectedObjectID,CurrentInfo);                                                                              
                    });                         

                    return {
                    oDS: MyDataSource,
                    oDT: MyDataTable
                    };
                }();

0 个答案:

没有答案