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