提交 | 用户 | age
|
25ab64
|
1 |
// ----------------------------------------------------------------------------------------------------------- |
F |
2 |
// Freeing memory |
|
3 |
// ----------------------------------------------------------------------------------------------------------- |
|
4 |
// ----------------------------------------------------------------------------------------------------------- |
|
5 |
// Deletes the grid |
|
6 |
|
|
7 |
TGP.Dispose = function(){ |
|
8 |
this.Clear(1); |
|
9 |
delete Grids[this.id]; |
|
10 |
Grids[this.Index] = null; |
|
11 |
if(Grids.Active==this) Grids.Active = null; |
|
12 |
if(Grids.Focused==this) Grids.Focused = null; |
|
13 |
} |
|
14 |
// ----------------------------------------------------------------------------------------------------------- |
|
15 |
// Deletes all grids on page |
|
16 |
MS.Api; |
|
17 |
function DisposeGrids(){ |
|
18 |
for(var i=0;i<Grids.length;i++){ |
|
19 |
var G = Grids[i]; |
|
20 |
if(G && Grids[G.id]==G) G.Dispose(); |
|
21 |
} |
|
22 |
Grids.length = 0; |
|
23 |
} |
|
24 |
var TGDisposeGrids = DisposeGrids; if(window["DisposeGrids"]==null) window["DisposeGrids"] = DisposeGrids; |
|
25 |
ME.Api; |
|
26 |
// ----------------------------------------------------------------------------------------------------------- |
|
27 |
// Clears links with HTML |
|
28 |
TGP.ClearChildren = function(row,type,S){ |
|
29 |
if(!row.firstChild) return; |
|
30 |
MS.Animate; this.FinishAnimations(row); ME.Animate; |
|
31 |
MS.ColPaging; |
|
32 |
if(!S && this.ColPaging){ |
|
33 |
S = []; var C = this.ColNames; |
|
34 |
for(var i=this.FirstSec;i<=this.LastSec;i++) if(C[i].State==4||i==1) S[S.length] = i; |
|
35 |
} |
|
36 |
ME.ColPaging; |
|
37 |
for(var r=row.firstChild;r;r=r.nextSibling){ |
|
38 |
if(Grids.OnClearRow && !r.Page) Grids.OnClearRow(this,r); |
|
39 |
MS.Nested; |
|
40 |
if(r.DetailCol && r.DetailGrid) { |
|
41 |
if(type==1) { |
|
42 |
r.DetailGrid[0].Dispose(); |
|
43 |
r.DetailGrid = null; |
|
44 |
r.DetailRow = null; |
|
45 |
} |
|
46 |
else r.DetailGrid[0].Clear(2); |
|
47 |
} |
|
48 |
ME.Nested; |
|
49 |
if(type==1&&r.MasterRow) this.DelDetail(r); |
|
50 |
if(r.r1 && !r.Page) this.RowCount--; |
|
51 |
if(this.SetIds){ |
|
52 |
if((type==1 || type==4) && !r.Page) delete this.Rows[r.id]; |
|
53 |
if(r.r1) { |
|
54 |
if(S) { for(var i=0;i<S.length;i++) r["r"+S[i]] = null; } |
|
55 |
else for(var i=this.FirstSec;i<=this.LastSec;i++) if(r["r"+i]) r["r"+i] = null; |
|
56 |
} |
|
57 |
if(r.rch1) { |
|
58 |
if(S) { for(var i=0;i<S.length;i++) r["rch"+S[i]] = null; } |
|
59 |
else for(var i=this.FirstSec;i<=this.LastSec;i++) if(r["rch"+i]) r["rch"+i] = null; |
|
60 |
} |
|
61 |
} |
|
62 |
else { |
|
63 |
if(r.r1) for(var i=this.FirstSec;i<=this.LastSec;i++) if(r["r"+i]) { r["r"+i].row = null; r["r"+i] = null; } |
|
64 |
if(r.rch1) for(var i=this.FirstSec;i<=this.LastSec;i++) if(r["rch"+i]) r["rch"+i] = null; |
|
65 |
} |
|
66 |
if(type==1&&r.Def&&r.Def.Name) r.Def = r.Def.Name; |
|
67 |
if(r.State>=3) r.State = 2; |
|
68 |
else if(r.State==1&&type==1) r.State = 0; |
|
69 |
if(r.firstChild) this.ClearChildren(r,type,S); |
|
70 |
r.Hasch = 0; |
|
71 |
} |
|
72 |
} |
|
73 |
// ----------------------------------------------------------------------------------------------------------- |
|
74 |
// Clears links with HTML in the given column section |
|
75 |
TGP.ClearSec = function(sec){ |
|
76 |
var F = this.GetFixedRows(); for(var j=0;j<F.length;j++) if(F[j]["r"+sec]){ F[j]["r"+sec].row = null; F[j]["r"+sec] = null; } |
|
77 |
this.XF["r"+sec] = null; |
|
78 |
function Clear(row){ |
|
79 |
for(var r=row.firstChild;r;r=r.nextSibling) { |
|
80 |
if(this.SetIds) { r["r"+sec] = null; if(r.rch1) r["rch"+sec] = null; } |
|
81 |
else if(r["r"+sec]){ r["r"+sec].row = null; r["r"+sec] = null; } |
|
82 |
else if(r["rch"+sec]){ r["rch"+sec].row = null; r["rch"+sec] = null; } |
|
83 |
if(r.firstChild) Clear(r); |
|
84 |
} |
|
85 |
} |
|
86 |
Clear(this.XB); |
|
87 |
|
|
88 |
} |
|
89 |
// ----------------------------------------------------------------------------------------------------------- |
|
90 |
// Clears whole grid |
|
91 |
// type = 0 - only links html - xml, 1 - all, include main tag |
|
92 |
// Function is written due memory dealocation, if it is not called from Render, Reload or unload, the browser (especially IE) does not free memory allocation |
|
93 |
TGP.Clear = function(type,S){ |
|
94 |
this.ReloadIndex++; |
|
95 |
if(type==null) type = 1; |
|
96 |
MS.ColPaging; if(this.ColPaging) for(var i=0,CN=this.ColNames;i<CN.length;i++) if(CN[i].State&1) CN[i].State--; ME.ColPaging; |
|
97 |
this.UpdateRowsHeightsTimeout = null; |
|
98 |
this.ChildPartsTmp = {}; |
|
99 |
this.ServerEdit = 0; |
|
100 |
if(this.XB) if(Try) { |
|
101 |
|
|
102 |
// --- Variable rows --- |
|
103 |
this.ClearChildren(this.XB,type,S); |
|
104 |
for(var r=this.XB.firstChild;r;r=r.nextSibling) if(r.State==3||r.State==1&&type==1) r.State--; |
|
105 |
|
|
106 |
if(type&3) { |
|
107 |
|
|
108 |
// --- fixed rows --- |
|
109 |
var F = this.GetFixedRows(); for(var j=0;j<F.length;j++){ |
|
110 |
var r = F[j]; |
|
111 |
if(Grids.OnClearRow) Grids.OnClearRow(this,r); |
|
112 |
if(this.SetIds){ |
|
113 |
for(var i=this.FirstSec;i<=this.LastSec;i++) r["r"+i] = null; |
|
114 |
} |
|
115 |
else { |
|
116 |
for(var i=this.FirstSec;i<=this.LastSec;i++) if(r["r"+i]) { r["r"+i].row = null; r["r"+i] = null; } |
|
117 |
} |
|
118 |
if(type==1){ r.Def = null; r.CalcOrder = null; } |
|
119 |
} |
|
120 |
for(var i=this.FirstSec;i<=this.LastSec;i++) this.XF["r"+i] = null; |
|
121 |
|
|
122 |
// --- space rows --- |
|
123 |
MS.Space; |
|
124 |
for(var r=this.XS.firstChild;r;r=r.nextSibling){ |
|
125 |
if(Grids.OnClearRow) Grids.OnClearRow(this,r); |
|
126 |
if(r.r1) r.r1.row = null; |
|
127 |
r.r1 = null; |
|
128 |
if(type==1){ r.Cells = null; r.Def = null; r.CalcOrder = null; } |
|
129 |
} |
|
130 |
ME.Space; |
|
131 |
|
|
132 |
this.ClearCursors(); |
|
133 |
} |
|
134 |
} |
|
135 |
else if(Catch) { } |
|
136 |
|
|
137 |
// --- ARow --- |
|
138 |
if(this.ARow && (!this.ARow.Fixed||type&11)) this.ARow = null; |
|
139 |
|
|
140 |
// --- master / detail --- |
|
141 |
MS.Master; |
|
142 |
if(type&5 && this.MasterGrid){ |
|
143 |
var B = this.XB.firstChild; |
|
144 |
this.MasterGrid.DetailSelected = null; |
|
145 |
if(B && B.MasterRow) { this.ClearMaster(B.MasterRow); B.MasterRow = null; } |
|
146 |
} |
|
147 |
ME.Master; |
|
148 |
|
|
149 |
// --- main tag --- |
|
150 |
if(type&9 && this.MainTag){ |
|
151 |
|
|
152 |
this.Loading = 0; |
|
153 |
this.Rendering = 0; |
|
154 |
this.MainTag.innerHTML = ""; |
|
155 |
} |
|
156 |
|
|
157 |
// --- html --- |
|
158 |
if(type&9){ |
|
159 |
MS.Message; |
|
160 |
if(Try){ |
|
161 |
this.HideMessage(1); |
|
162 |
var P = [this.ShowHintTag,this.RotWidthTag,this.FFScroll]; |
|
163 |
var M = this.Message; if(M) { P.push(M.Tag,M.Shadow,M.Disabled); this.Message = null; } |
|
164 |
for(var i=0;i<P.length;i++) if(P[i]) P[i].parentNode.removeChild(P[i]); |
|
165 |
this.ShowHintTag = null; this.RotWidthTag = null; this.FFScroll = null; |
|
166 |
} else if(Catch) { } |
|
167 |
ME.Message; |
|
168 |
if(Try){ this.HideTip(); } else if(Catch) { } |
|
169 |
if(Try){ this.CloseDialog(); } else if(Catch) { } |
|
170 |
if(Try){ this.HideHint(1); } else if(Catch) { } |
|
171 |
MS.MaxHeight; DelArea(this.MainTag); ME.MaxHeight; |
|
172 |
if(Try){ for(var i=0;i<Dialogs.length;i++) if(Dialogs[i] && Dialogs[i].Grid==this && Dialogs[i].Close) Dialogs[i].Close(); } else if(Catch) { } |
|
173 |
var X = this.HiddenStyle; if(!X) X = GetElem(this.GetItemId("FastColumns")); if(X) X.innerHTML = ""; |
|
174 |
} |
|
175 |
|
|
176 |
// --- all data --- |
|
177 |
if(type&1){ |
|
178 |
this.FRow = null; this.SRow = null; |
|
179 |
if(Try){ ClearChildren(this.XB); } else if(Catch) { } |
|
180 |
if(Try){ ClearChildren(this.XF); } else if(Catch) { } |
|
181 |
if(Try){ ClearChildren(this.XH); } else if(Catch) { } |
|
182 |
if(Try){ ClearChildren(this.XS); } else if(Catch) { } |
|
183 |
|
|
184 |
this.SpannedCols = []; this.SpannedColsLength = 0; |
|
185 |
this.RemovedCols = {}; |
|
186 |
this.Cleared = 1; this.LoadedCount = 0; |
|
187 |
} |
|
188 |
|
|
189 |
} |
|
190 |
// ----------------------------------------------------------------------------------------------------------- |