source: branches/2.2.0.1/calendar/js/dhtmlx/codebase/connector/connector.js @ 4001

Revision 4001, 4.5 KB checked in by rafaelraymundo, 13 years ago (diff)

Ticket #1615 - Componente novo para agenda......................................

Line 
1/*
2This software is allowed to use under GPL or you need to obtain Commercial or Enterise License
3to use it in not GPL project. Please contact sales@dhtmlx.com for details
4
5(c) DHTMLX Ltd.
6*/
7/*
8        dhx_sort[index]=direction
9        dhx_filter[index]=mask
10*/
11if (window.dhtmlXGridObject){
12        dhtmlXGridObject.prototype._init_point_connector=dhtmlXGridObject.prototype._init_point;
13        dhtmlXGridObject.prototype._init_point=function(){
14                var clear_url=function(url){
15                        url=url.replace(/(\?|\&)connector[^\f]*/g,"");
16                        return url+(url.indexOf("?")!=-1?"&":"?")+"connector=true";
17                }
18                var combine_urls=function(url){
19                        return clear_url(url)+(this._connector_sorting||"")+(this._connector_filter||"");
20                }
21                var sorting_url=function(url,ind,dir){
22                        this._connector_sorting="&dhx_sort["+ind+"]="+dir;
23                        return combine_urls.call(this,url);
24                }
25                var filtering_url=function(url,inds,vals){
26                        for (var i=0; i<inds.length; i++)
27                                inds[i]="dhx_filter["+inds[i]+"]="+encodeURIComponent(vals[i]);
28                        this._connector_filter="&"+inds.join("&");
29                        return combine_urls.call(this,url);
30                }
31                this.attachEvent("onCollectValues",function(ind){
32                        if (this._con_f_used[ind]){
33                                if (typeof(this._con_f_used[ind]) == "object")
34                                        return this._con_f_used[ind];
35                                else
36                                        return false;
37                        }
38                        return true;
39                });     
40                this.attachEvent("onDynXLS",function(){
41                                this.xmlFileUrl=combine_urls.call(this,this.xmlFileUrl);
42                                return true;
43                });                             
44                this.attachEvent("onBeforeSorting",function(ind,type,dir){
45                        if (type=="connector"){
46                                var self=this;
47                                this.clearAndLoad(sorting_url.call(this,this.xmlFileUrl,ind,dir),function(){
48                                        self.setSortImgState(true,ind,dir);
49                                });
50                                return false;
51                        }
52                        return true;
53                });
54                this.attachEvent("onFilterStart",function(a,b){
55                        if (this._con_f_used.length){
56                                this.clearAndLoad(filtering_url.call(this,this.xmlFileUrl,a,b));
57                                return false;
58                        }
59                        return true;
60                });
61                this.attachEvent("onXLE",function(a,b,c,xml){
62                        if (!xml) return;
63                });
64               
65                if (this._init_point_connector) this._init_point_connector();
66        }
67        dhtmlXGridObject.prototype._con_f_used=[];
68        dhtmlXGridObject.prototype._in_header_connector_text_filter=function(t,i){
69                if (!this._con_f_used[i])
70                        this._con_f_used[i]=1;
71                return this._in_header_text_filter(t,i);
72        }
73        dhtmlXGridObject.prototype._in_header_connector_select_filter=function(t,i){
74                if (!this._con_f_used[i])
75                        this._con_f_used[i]=2;
76                return this._in_header_select_filter(t,i);
77        }
78        dhtmlXGridObject.prototype.load_connector=dhtmlXGridObject.prototype.load;
79        dhtmlXGridObject.prototype.load=function(url, call, type){
80                if (!this._colls_loaded && this.cellType){
81                        var ar=[];
82                        for (var i=0; i < this.cellType.length; i++)
83                                if (this.cellType[i].indexOf("co")==0 || this._con_f_used[i]==2) ar.push(i);
84                        if (ar.length)
85                                arguments[0]+=(arguments[0].indexOf("?")!=-1?"&":"?")+"connector=true&dhx_colls="+ar.join(",");
86                }
87                return this.load_connector.apply(this,arguments);
88        }
89        dhtmlXGridObject.prototype._parseHead_connector=dhtmlXGridObject.prototype._parseHead;
90        dhtmlXGridObject.prototype._parseHead=function(url, call, type){
91                this._parseHead_connector.apply(this,arguments);
92                if (!this._colls_loaded){
93                        var cols = this.xmlLoader.doXPath("./coll_options", arguments[0]);
94                        for (var i=0; i < cols.length; i++){
95                                var f = cols[i].getAttribute("for");
96                                var v = [];
97                                var combo=null;
98                                if (this.cellType[f] == "combo")
99                                        combo = this.getColumnCombo(f);
100                                if (this.cellType[f].indexOf("co")==0)
101                                        combo=this.getCombo(f);
102                                       
103                                var os = this.xmlLoader.doXPath("./item",cols[i]);
104                                for (var j=0; j<os.length; j++){
105                                        var val=os[j].getAttribute("value");
106                                       
107                                        if (combo){
108                                                var lab=os[j].getAttribute("label")||val;
109                                               
110                                                if (combo.addOption)
111                                                        combo.addOption([[val, lab]]);
112                                                else
113                                                        combo.put(val,lab);
114                                                       
115                                                v[v.length]=lab;
116                                        } else
117                                                v[v.length]=val;
118                                }
119                                if (this._con_f_used[f*1])
120                                        this._con_f_used[f*1]=v;
121                        };
122                        this._colls_loaded=true;
123                }
124        }       
125       
126       
127       
128
129}
130
131if (window.dataProcessor){
132        dataProcessor.prototype.init_original=dataProcessor.prototype.init;
133        dataProcessor.prototype.init=function(obj){
134                this.init_original(obj);
135                obj._dataprocessor=this;
136               
137                this.setTransactionMode("POST",true);
138                this.serverProcessor+=(this.serverProcessor.indexOf("?")!=-1?"&":"?")+"editing=true";
139        }
140}
141dhtmlxError.catchError("LoadXML",function(a,b,c){
142        alert(c[0].responseText);
143});
Note: See TracBrowser for help on using the repository browser.