提交 | 用户 | age
|
25ab64
|
1 |
// ----------------------------------------------------------------------------------------------------------- |
F |
2 |
// Functions for row manipulations - adding, deleting |
|
3 |
// ----------------------------------------------------------------------------------------------------------- |
|
4 |
// ----------------------------------------------------------------------------------------------------------- |
|
5 |
// Add new row to parent before row nex |
|
6 |
// If next==null add it as the last row of parent's children |
|
7 |
// If next and parent are null, adds row to last of actual page |
|
8 |
// If show==true, shows the in row in table |
|
9 |
// if id is set, does not generate id, but sets it |
|
10 |
// If set Def uses this name |
|
11 |
MS.Add; |
|
12 |
TGP.AddRow = function(par,next,show,id,Def,src,master,test,A,old,noundo){ |
|
13 |
if(next) par = next.parentNode; |
|
14 |
if(!par){ |
|
15 |
if(!this.AllPages) par = GetNode(this.XB,this.FPage); |
|
16 |
else par = this.XB.lastChild; |
|
17 |
} |
|
18 |
|
|
19 |
if(!src && !Def && !par.Page && Is(par,"AddParent")) return this.AddRow(par.parentNode,Get(par,"AddParent")==2?null:par,show,id,Def,src,master,test); |
|
20 |
if(next && par.Page && this.Root.AddParent==2) next = null; |
|
21 |
|
|
22 |
var D; |
|
23 |
if(src) D = this.Def[src.Def.Name]; |
|
24 |
if(D) { if(!src.CPage && !this.TestDef(par,D.Name)&&(!old||typeof(old)!="object")) return null; } |
|
25 |
else { |
|
26 |
var def = Def; if(!def) { def = Get(par.Page?this.Root:par,"CDef"); if(!def) return null; } |
|
27 |
D = this.Def[def]; if(!D) { |
|
28 |
MS.Debug; if(!test) this.Debug(1,"Not defined default row ",def,", cannot add new row to this grid"); ME.Debug; |
|
29 |
return null; |
|
30 |
} |
|
31 |
} |
|
32 |
|
|
33 |
MS._Free; |
|
34 |
MS._Debug;if(0){ ME._Debug; |
|
35 |
var cnt = 26+7; |
|
36 |
for(var r=this.GetFirst();r;r=this.GetNext(r),cnt--) if(cnt<=1) return null; |
|
37 |
MS._Debug;} ME._Debug; |
|
38 |
ME._Free; |
|
39 |
|
|
40 |
if(!this.HasChildren(par)) par.State = 4; |
|
41 |
if(par.State<2) return null; |
|
42 |
if(test&&this.Group&&!this.MainColGroup&&par.Def&&!par.Def.Group&&this.GroupMoveFree!=2) return null; |
|
43 |
if(test) return true; |
|
44 |
if(!par.Page && Get(par,"DefParent") && !this.HasNDChildren(par)) this.ChangeDef(par,Get(par,"DefParent"),1,2); |
|
45 |
var r = old&&typeof(old)=="object" ? old : Dom.createElement("I"); if(r.Removed) delete r.Removed; |
|
46 |
if(next) par.insertBefore(r,next); |
|
47 |
else { |
|
48 |
if(this.Paging==3 && par.tagName=="BR") par = this.UpdateTagName(par); |
|
49 |
par.appendChild(r); |
|
50 |
} |
|
51 |
r.Def = D; |
|
52 |
r.Expanded = D.Expanded ? D.Expanded-0 : 0; |
|
53 |
r.Kind = D.Kind; |
|
54 |
r.Calculated = D.Calculated ? 1 : 0; |
|
55 |
r.Visible = D.Visible ? 1 : 0; |
|
56 |
r.Spanned = D.Spanned ? 1 : 0; |
|
57 |
if(r.Spanned) this.UpdateSpan(r); |
|
58 |
r.Level = par.SPage ? par.Level : par.Level+1; |
|
59 |
|
|
60 |
r.Added = 1; |
|
61 |
r.Visible = 0; |
|
62 |
r.State = r.Expanded ? 4 : 2; |
|
63 |
r.DetailCol = D.DetailCol; |
|
64 |
for(var c in this.Cols) if(c!="Panel" && !Get(r,c)) r[c] = this.GetValue(r,c); |
|
65 |
if(this.DefaultSortPos) r[this.DefaultSort] = this.DefaultSortPos++; |
|
66 |
this.LoadedCount++; |
|
67 |
|
|
68 |
|
|
69 |
MS.Master; |
|
70 |
if(D.EditCols){ |
|
71 |
var EC = (D.EditCols+"").split(','); |
|
72 |
for(var i=0;i<EC.length;i++){ |
|
73 |
var c = EC[i]; |
|
74 |
if(c=="Main" || c=="MainCol"){ |
|
75 |
MS.Tree; |
|
76 |
MS.Group; |
|
77 |
if(this.Group){ |
|
78 |
var gc = this.GetGroupCol(r); |
|
79 |
if(gc){ |
|
80 |
r[this.MainCol+"CopyTo"] = "Children,"+gc; |
|
81 |
r[this.MainCol+"CanEdit"] = 1; |
|
82 |
r[this.MainCol] = Get(r,gc); |
|
83 |
} |
|
84 |
} |
|
85 |
ME.Group; |
|
86 |
ME.Tree; |
|
87 |
} |
|
88 |
else { |
|
89 |
r[c+"CopyTo"] = "Children,"+c; |
|
90 |
r[c+"CanEdit"] = 1; |
|
91 |
} |
|
92 |
} |
|
93 |
r.HasCopyTo = 1; |
|
94 |
} |
|
95 |
if(par.Def && (par.Def.Group || par.Def.HasCopyTo) || par.HasCopyTo) this.UpdateCopyTo(r,par); |
|
96 |
ME.Master; |
|
97 |
|
|
98 |
if(src){ |
|
99 |
var N = {DetailRow:1,DetailGrid:1,MasterRow:1,Def:1,r0:1,r1:1,r2:1,Count:1,Hasch:1,id:1,Level:1,LevelImg:1,Added:1,Filtered:1,HasIndex:1,Updated:1}; |
|
100 |
if(src.RowSpan) for(var c in this.Cols) { N[c+"RowSpan"] = 1; N.RowSpan = 1; } |
|
101 |
if(this.RowIndex) N[this.RowIndex] = 1; |
|
102 |
if(D!=src.Def && (!Grids.OnRowCopyDef||!Grids.OnRowCopyDef(this,r,src,src.WillMove?1:0))) for(var i in src.Def) if(!Grids.INames[i] && !N[i] && src.Def[i]!=null) r[i] = src.Def[i]; |
|
103 |
if(this.EditAttrs){ |
|
104 |
if(!A) A = this.GetEditAttrs(3,null,{RowSpan:1}); var al = A.length; |
|
105 |
if(al) for(var c in this.Cols) for(var i=0;i<al;i++) r[c+A[i]] = src[c+A[i]]; |
|
106 |
} |
|
107 |
else for(var i in src) if(!Grids.INames[i] && !N[i] && src[i]!=null) r[i] = src[i]; |
|
108 |
r.Selected = 0; r.Visible = 0; r.Hasch = 0; r.State = 4; |
|
109 |
} |
|
110 |
if(id) { |
|
111 |
r.id = id; |
|
112 |
if(this.SetIds) this.SetRowsId(r); |
|
113 |
} |
|
114 |
else if(src){ |
|
115 |
|
|
116 |
if(!Grids.OnRowCopyId || !Grids.OnRowCopyId(this,r,src,src.WillMove?1:0)) this.SetRowId(r); |
|
117 |
else if(this.SetIds) this.SetRowsId(r); |
|
118 |
} |
|
119 |
else this.SetRowId(r); |
|
120 |
if(this.AllSelected && !r.Selected && this.CanSelect(r)) { |
|
121 |
if(this.SelectAllType&16) r.Selected = 1; |
|
122 |
else this.SetAllSelected(0); |
|
123 |
} |
|
124 |
|
|
125 |
MS.Undo; |
|
126 |
if(!this.MasterGrid&&!noundo) { |
|
127 |
this.AddUndo({ Type:"Add",Row:r,Parent:par,Next:next,Id:r.id,Def:r.Def.Name,Src:src,SrcVisible:src?src.Visible:null }); |
|
128 |
if(this.SaveOrder && !Is(r,"NoUpload")) this.SetChange({ Row:r.id,Parent:par.id?par.id:par.Pos,Next:next?next.id:null,Added:1,Copy:src?src.id:"" },1); |
|
129 |
} |
|
130 |
ME.Undo; |
|
131 |
|
|
132 |
var mergeundo = 0; |
|
133 |
MS.Group; if(this.Group && this.Grouped && this.GroupChangeMoved) if(this.UpdateRowGroups(r,0)) mergeundo++; ME.Group; |
|
134 |
|
|
135 |
MS.Tree; |
|
136 |
if(D.Children && !src && !old){ |
|
137 |
for(var i=0;i<D.Children.length;i++){ |
|
138 |
var d = D.Children[i]; |
|
139 |
if(d.Def==D) continue; |
|
140 |
var ch = this.AddRow(r,null,false,null,d.Def.Name); mergeundo++; |
|
141 |
for(var j in d) if(j!="id" && !this.IdTypes[j]) ch[j] = d[j]; |
|
142 |
} |
|
143 |
this.UpdateChildrenLevelImg(r); |
c35f05
|
144 |
MS.RowSpan; |
F |
145 |
if(this.RowSpan&&r.firstChild) { |
|
146 |
var chg = 0; |
|
147 |
for(var col in this.SpanCols) if(this.CreateRowSpan(r,col)) chg++; |
|
148 |
if(chg&&!noundo&&this.Undo&1) this.AddUndo({ Type:"CreateRowSpan", Row:r }); |
|
149 |
} |
|
150 |
ME.RowSpan; |
25ab64
|
151 |
r.State = 2; |
F |
152 |
} |
|
153 |
ME.Tree; |
|
154 |
|
|
155 |
MS.Undo; |
|
156 |
while(mergeundo--) this.MergeUndo(); |
|
157 |
ME.Undo; |
|
158 |
|
|
159 |
MS.RowSpan; |
|
160 |
if(this.RowSpan) { |
|
161 |
var O = {}, U = null; |
|
162 |
if(this.Undo&1&&this.OUndo) U = this.GetUndoSpan(O); |
|
163 |
this.AddRowSpan([r],O,U); |
|
164 |
if(U) this.AddUndo({ Type:"AddSpan",Data:U },1); |
|
165 |
for(var ro in O) this.RefreshRow(O[ro]); |
|
166 |
} |
|
167 |
ME.RowSpan; |
|
168 |
|
|
169 |
MS.CPages; |
|
170 |
if(par.CPage) this.UpdateCPages(par.parentNode,show); |
|
171 |
ME.CPages; |
|
172 |
|
|
173 |
MS.Gantt; |
|
174 |
MS.GanttResources; |
|
175 |
if(this.ResourcesGrid){ |
|
176 |
var G = this.ResourcesGrid, N = r[this.GanttResourcesName]; if(N==null) N = D[this.GanttResourcesName]; |
|
177 |
G.Resources[N] = { Name: N, Type: Get(r,this.GanttResourcesType), Price: Get(r,this.GanttResourcesPrice), Availability: Get(r,this.GanttResourcesAvailability) }; |
|
178 |
r[this.GanttResourcesChart+"GanttChartResource"] = N; |
|
179 |
G.Calculate(1); |
|
180 |
} |
|
181 |
ME.GanttResources; |
|
182 |
ME.Gantt; |
|
183 |
|
|
184 |
if(show&4 && !master){ |
|
185 |
if(Grids.OnRowAdd) Grids.OnRowAdd(this,r); |
|
186 |
if(src && Grids.OnRowCopy) Grids.OnRowCopy(this,r,src); |
|
187 |
} |
|
188 |
if(show&3 && (!src||Is(src,"Visible"))){ |
|
189 |
if(this.MainTable) this.ShowRow(r); |
|
190 |
else r.Visible = 1; |
|
191 |
this.UpdateRowIcons(r); |
|
192 |
if(show&2) this.ExpandParents(r); |
|
193 |
} |
|
194 |
//**----------- |
|
195 |
if(!this.isCopy){//add |
|
196 |
|
|
197 |
this.setdoctiemNum(); |
|
198 |
this.InitSetValue(r);//在显示行之前增加初始值 by 2011-4-26 |
|
199 |
this.setMuts(r); |
|
200 |
this.setCpLtRow(r);//插入时从上行复制 |
|
201 |
this.prossExpr(true,r); |
|
202 |
this.RefreshRow(r); |
|
203 |
//if(flg==undefined) this.setColFocus(r);//flg=true表示是tab键触发,不需要设置焦点 |
|
204 |
}else{//update |
|
205 |
this.isCopy=false |
|
206 |
this.setdoctiemNum(); |
|
207 |
this.delcopyfields(r); |
|
208 |
this.setMuts(r); |
|
209 |
this.isCS=true; |
|
210 |
this.setCpLtRow(r);//插入时从上行复制 |
|
211 |
this.RefreshRow(r); |
|
212 |
} |
|
213 |
//**------ |
|
214 |
MS.Master; |
|
215 |
if(!(master&1) && par.MasterRow){ |
|
216 |
var nr = this.MasterGrid.AddRow(par.MasterRow,next?next.MasterRow:null,show&~2,id,Def,src,2); |
|
217 |
r.MasterRow = nr; |
|
218 |
if(nr){ |
|
219 |
if(nr.DetailRow) { nr.DetailRow[nr.DetailRow.length] = r; nr.DetailGrid[nr.DetailGrid.length] = this; } |
|
220 |
else { nr.DetailRow = [r]; nr.DetailGrid = [this]; } |
|
221 |
} |
|
222 |
} |
|
223 |
if(par.DetailRow&&!(master&2)) this.AddInDetail(r,show,master?src:null); |
|
224 |
|
|
225 |
ME.Master; |
|
226 |
|
|
227 |
MS.Pivot; if(this.PivotGrid) this.AddPivotRow(r,src); ME.Pivot; |
|
228 |
|
|
229 |
if(show&4) { |
|
230 |
MS.Gantt; if(this.GanttDependency) this.TaskChanged |= 16; ME.Gantt; |
|
231 |
this.Recalculate(r,null,true); |
|
232 |
if(!this.MasterGrid) this.UploadChanges(r); |
|
233 |
if(this.SaveValues) this.SaveCfg(); |
|
234 |
} |
|
235 |
if(r.docitem!=undefined&&r.docitem=="") {//****** by2014-7-23 增加对行号的处理, |
|
236 |
this.docitem+=10; |
|
237 |
this.SetValue(r, "docitem",this.docitem , true); |
|
238 |
} |
|
239 |
this.newRow=r;//*****保存增加行到变量里面,以便通过快捷键Ins能重新排序放到最后 |
|
240 |
return r; |
|
241 |
} |
|
242 |
// ----------------------------------------------------------------------------------------------------------- |
|
243 |
TGP.AddRows = function(cnt,par,next,focus,test,noupload,id,paste,src){ |
|
244 |
this.cpRow=this.GetLastRow(); |
|
245 |
if(!this.isCopy){//***不是复行时,增加面板检查 |
|
246 |
if(typeof(panMain)!="undefined"&& panMain[panIndex].checkToGrid){ |
|
247 |
if(!panMain[panIndex].checkToGrid()) return false; |
|
248 |
} |
|
249 |
} |
|
250 |
if(!this.Adding||this.Locked["addrow"] || this.Detail && !this.XB.firstChild.MasterRow) return null; |
c35f05
|
251 |
if(Grids.OnCanRowAdd) { |
F |
252 |
var tmp = Grids.OnCanRowAdd(this,par,next); |
|
253 |
if(!tmp&&tmp!=null) return null; |
|
254 |
if(tmp&&typeof(tmp)=="object"){ |
|
255 |
if(tmp[0]!=null) par = tmp[0]; |
|
256 |
if(tmp[1]!=null) next = tmp[1]; |
|
257 |
} |
|
258 |
} |
25ab64
|
259 |
if(this.Group&&!this.MainColGroup&&par&&par.Def&&!par.Def.Group&&this.GroupMoveFree!=2) return null; |
F |
260 |
//*****增加树+格线,没选择树节点时候增加提示 |
|
261 |
var treefl=true; |
|
262 |
if (typeof (isclick) != "undefined") { |
|
263 |
if (isclick != undefined && isclick == false) { |
|
264 |
alert(this.GetText("treeNode")); |
|
265 |
treefl=false; |
|
266 |
test=true; |
|
267 |
} |
|
268 |
} |
|
269 |
//***** |
665b06
|
270 |
if(test){ |
F |
271 |
this.isCopy=false; |
|
272 |
return this.AddRow(par,next,null,null,null,null,null,1) ? 1 : 0; |
|
273 |
} |
25ab64
|
274 |
MS.Animate; this.FinishAnimations(); ME.Animate; |
F |
275 |
this.UndoStart(); |
|
276 |
this.StartUpdate(); |
|
277 |
var A = [], p = 0; |
|
278 |
for(var i=cnt?cnt:1,fr=null;i>0;i--){ |
|
279 |
var r = this.AddRow(par,next,(noupload?1:5)+(paste?0:2),id,null,src); |
|
280 |
if(!r){ |
|
281 |
this.EndUpdate(); |
|
282 |
this.ShowMessageTime(par&&!par.Page?this.GetText("ErrAdd").replace("%1",this.GetName(par)):this.GetText("ErrAddRoot"),this.EditErrorsMessageTime?this.EditErrorsMessageTime:1000); |
|
283 |
return null; |
|
284 |
} |
|
285 |
if(Grids.OnRowAdded) Grids.OnRowAdded(this,r,paste); |
|
286 |
A[p++] = r; |
|
287 |
} |
|
288 |
this.EndUpdate(A.length==1?A[0]:null); |
|
289 |
if(focus) { |
|
290 |
var r1 = A[0], r2 = A[A.length-1], G = this; |
|
291 |
while(r1&&r1.DetailRow&&r2.DetailRow&&!r1.DetailRow[0].Page) { |
|
292 |
|
|
293 |
G = r1.DetailGrid[0]; r1 = r1.DetailRow[0]; r2 = r2.DetailRow[0]; |
|
294 |
} |
|
295 |
G.FocusRows(r1,r2); |
|
296 |
} |
|
297 |
this.UndoEnd(); |
|
298 |
this.CalcTreeWidth(); |
|
299 |
//MS.Animate; if(cnt>1) this.AnimRows(A,"AddRows",1); else this.AnimRow(A[0],"Add",1); ME.Animate;//***在另一个页卡选择返回填充当前treegrid时在frieFox上会出现只填充一行,其他行隐藏不显示的问题,所以这里暂时去掉 |
|
300 |
return cnt?A:A[0]; |
|
301 |
} |
|
302 |
// ----------------------------------------------------------------------------------------------------------- |
|
303 |
TGP.GetActualPage = function(){ |
|
304 |
if(!this.Paging) return this.XB.firstChild; |
|
305 |
MS.Paging; |
|
306 |
if(this.AllPages){ |
|
307 |
if(this.FRow && !this.FRow.Fixed) return this.GetRowPage(this.FRow); |
|
308 |
var A = this.GetShowedPages(); |
|
309 |
return GetNode(this.XB,A[0]); |
|
310 |
} |
|
311 |
else return this.FPage!=null ? GetNode(this.XB,this.FPage) : null; |
|
312 |
ME.Paging; |
|
313 |
} |
|
314 |
// ----------------------------------------------------------------------------------------------------------- |
|
315 |
// ----------------------------------------------------------------------------------------------------------- |
|
316 |
TGP.DoAddRows = function(F,T,S,below){ |
|
317 |
if(!this.Adding||this.Locked["addrow"]) return false; |
|
318 |
if(this.EditAttrsEmpty) return S&4 ? this.CopyRow2(F,1,1,0,T) : this.CopySelectedRows(F,0,1,below?1:0,S&1,T); |
|
319 |
var row = this.GetARow(F&5?F&5:5,below?2:1); |
|
320 |
MS.Master; if(F&1&&!row&&this.FocusNested(T)&&this.LastFocus[0].Adding&&!(this.LastFocus[0].Locked["addrow"])) row = this.Rows[this.LastFocus[1]]; ME.Master; |
|
321 |
if(!row||row.Fixed) return false; |
|
322 |
var cnt = 0; |
|
323 |
if(!S) cnt = 1; |
|
324 |
else { |
|
325 |
var R = this.GetARows(S); |
|
326 |
for(var id in R) if(!R[id].Deleted) cnt++; |
|
327 |
} |
|
328 |
if(!cnt) return cnt; |
|
329 |
var A = this.AddRows(cnt,row.parentNode,below?row.nextSibling:row,1,T); if(!A) return false; |
|
330 |
if(T) return cnt; |
|
331 |
if(!below && row==this.ARow) this.ARow = A[0]; |
|
332 |
return true; |
|
333 |
} |
|
334 |
// ----------------------------------------------------------------------------------------------------------- |
|
335 |
TGP.ActionAddRow = function(F,T){ return this.DoAddRows(F,T,0,0); } |
|
336 |
TGP.ActionAddRowBelow = function(F,T){ return this.DoAddRows(F,T,0,1); } |
|
337 |
TGP.ActionAddRows = function(F,T){ return this.DoAddRows(F,T,F&~5|1,0); } |
|
338 |
TGP.ActionAddRowsBelow = function(F,T){ return this.DoAddRows(F,T,F&~5|1,1); } |
|
339 |
TGP.ActionAddSelected = function(F,T){ return this.DoAddRows(F,T,F&~5|2,0); } |
|
340 |
TGP.ActionAddSelectedBelow = function(F,T){ return this.DoAddRows(F,T,F&~5|2,1); } |
|
341 |
// ----------------------------------------------------------------------------------------------------------- |
|
342 |
TGP.ActionAddRowEndPage = function(F,T){ |
|
343 |
MS.Master; if(F&1&&this.FocusNested(T)&&this.LastFocus[0].Adding&&!(this.LastFocus[0].Locked["addrow"])) return this.LastFocus[0].ActionAddRowEndGrid(0,T); ME.Master; |
|
344 |
return !!this.AddRows(1,this.GetActualPage(),null,1,T); |
|
345 |
} |
|
346 |
// ----------------------------------------------------------------------------------------------------------- |
|
347 |
TGP.ActionAddRowEndGrid = function(F,T){ |
|
348 |
MS.Master; if(F&1&&this.FocusNested(T)&&this.LastFocus[0].Adding&&!(this.LastFocus[0].Locked["addrow"])) return this.LastFocus[0].ActionAddRowEndGrid(0,T); ME.Master; |
|
349 |
var b = this.XB.lastChild; |
|
350 |
if(T) return this.AddRows(1,b,null,1,T); |
|
351 |
if(this.Paging && !this.AllPages && this.FPage!=this.XB.childNodes.length-1) this.GoToPage(b); |
|
352 |
if(b.State!=4){ |
|
353 |
if(this.AllPages && (b.State==2||b.State==0)) { this.GoToPage(b); this.ShowPages(); } |
|
354 |
T = this; |
|
355 |
setTimeout(function(){T.ActionAddRowEndGrid();},100); |
|
356 |
return true; |
|
357 |
} |
|
358 |
return !!this.AddRows(1,b,null,1); |
|
359 |
} |
|
360 |
// ----------------------------------------------------------------------------------------------------------- |
|
361 |
TGP.ActionAddRowEnd = function(F,T){ |
|
362 |
this.isCopy=false; //**** |
|
363 |
return this.AllPages ? this.ActionAddRowEndGrid(F,T) : this.ActionAddRowEndPage(F,T); |
|
364 |
} |
|
365 |
// ----------------------------------------------------------------------------------------------------------- |
|
366 |
TGP.AddChild = function(F,type,test){ |
|
367 |
var row = this.GetARow(F); |
|
368 |
MS.Master; if(F&1&&!row&&this.FocusNested(test)&&this.LastFocus[0].Adding&&!(this.LastFocus[0].Locked["addrow"])) row = this.Rows[this.LastFocus[1]]; ME.Master; |
|
369 |
if(row==null || row.Fixed || row.Page || !this.MainCol || !Is(row,"AcceptChild")) return false; |
|
370 |
var next = type ? null : row.firstChild; |
|
371 |
if(this.AddChildType&1) type = 1; |
|
372 |
MS.Paging; |
|
373 |
var fc = row.firstChild; |
|
374 |
if(fc && fc.CPage || !fc && row.Count) { |
|
375 |
|
|
376 |
if(!row.Expanded && !row.Page && !test) this.Expand(row); |
|
377 |
if(row.State<4 && !test){ |
|
378 |
var T = this; |
|
379 |
setTimeout(function(){ T.AddChild(F,type); },100); |
|
380 |
return true; |
|
381 |
} |
|
382 |
MS.CPages; |
|
383 |
if(fc){ |
|
384 |
if(type) row = row.lastChild; |
|
385 |
else { row = fc; next = fc.firstChild; } |
|
386 |
} |
|
387 |
ME.CPages; |
|
388 |
} |
|
389 |
ME.Paging; |
|
390 |
//****保存上一级的rowid,到时给当前行的parentrowid用。以便建立关系 |
|
391 |
this.treeParentRowid=row.rowid||""; |
|
392 |
if(!this.AddRows(1,row,next,1,test)) return false; |
|
393 |
if(test) return row.Count ? row.Count+1 : row.childNodes.length+1; |
|
394 |
return true; |
|
395 |
} |
|
396 |
// ----------------------------------------------------------------------------------------------------------- |
|
397 |
TGP.ActionAddChild = function(F,T){ return this.AddChild(F,0,T); } |
|
398 |
TGP.ActionAddChildEnd = function(F,T){ return this.AddChild(F,1,T); } |
|
399 |
// ----------------------------------------------------------------------------------------------------------- |
|
400 |
ME.Add; |
|
401 |
|
|
402 |
// ----------------------------------------------------------------------------------------------------------- |
|
403 |
MS.Master; |
|
404 |
TGP.UpdateCopyTo = function(row,par,refresh){ |
|
405 |
var ppar = par.parentNode, D = par.Def; |
|
406 |
if(ppar && ppar.Def && ppar.Def.Group) this.UpdateCopyTo(row,ppar,refresh); |
|
407 |
for(var cc in this.Cols) { |
|
408 |
var cp = par[cc+"CopyTo"]; if(cp==null) cp = D[cc+"CopyTo"]; |
|
409 |
if(!cp) continue; |
|
410 |
cp = cp.split(','); |
|
411 |
for(var i=0;i<cp.length;i+=2){ |
|
412 |
var s = cp[i].split('_'); |
|
413 |
if(s[0]=="Child") { |
|
414 |
if(s[1]-0+""==s[1]) n = GetNode(par,s[1]-0); |
|
415 |
else for(var n=par.firstChild;n;n=n.nextSibling) if(n.Def==s[1]) break; |
|
416 |
if(n!=row) continue; |
|
417 |
} |
|
418 |
else if(s[0]!="Children") continue; |
|
419 |
if(refresh) this.SetValue(row,cp[i+1],Get(par,cc),1); |
|
420 |
else row[cp[i+1]] = Get(par,cc); |
|
421 |
} |
|
422 |
} |
|
423 |
} |
|
424 |
ME.Master; |
|
425 |
// ----------------------------------------------------------------------------------------------------------- |
|
426 |
MS.Group; |
|
427 |
TGP.UpdateRowGroups = function(row,show){ |
|
428 |
var G = this.Group.split(","), rows = [], M = this.MainCol; |
|
429 |
if(row.Def.Group){ |
|
430 |
for(var p=row;p&&p.Def.Group;p=p.firstChild); |
|
431 |
while(p){ rows[rows.length] = p; p = p.nextSibling; } |
|
432 |
} |
|
433 |
else rows[0] = row; |
|
434 |
if(!rows.length) return false; |
|
435 |
for(var p=rows[0].parentNode;p&&p.Def&&!p.Def.Group;p=p.parentNode); |
|
436 |
var v = {}; for(var i=0;i<G.length;i++) v[G[i]] = ""; |
|
437 |
for(;p&&p.Def&&p.Def.Group;p=p.parentNode) if(!p.SPage){ |
|
438 |
var c = this.GetGroupCol(p); |
|
439 |
if(c) v[c] = v[c] ? p[M] + this.Cols[c].GroupChar + v[c] : p[M]; |
|
440 |
} |
|
441 |
this.UndoStart(); |
|
442 |
for(var i=0;i<rows.length;i++) { |
|
443 |
for(var c in v) this.SetValue(rows[i],c,v[c],show); |
|
444 |
if(rows[i]!=row && rows[i].firstChild) this.UpdateRowGroups(rows[i],show); |
|
445 |
} |
|
446 |
this.UndoEnd(); |
|
447 |
return true; |
|
448 |
} |
|
449 |
ME.Group; |
|
450 |
// ----------------------------------------------------------------------------------------------------------- |
|
451 |
// ----------------------------------------------------------------------------------------------------------- |
|
452 |
// Deletes row from table, and also all references to it |
|
453 |
MS.Show; |
|
454 |
TGP.DelRow = function(row,nonested){ |
|
455 |
if(row.Removed && row.Removed!=-1) return; |
c35f05
|
456 |
if(Grids.OnRowRemove && Grids.OnRowRemove(this,row)) return; |
25ab64
|
457 |
row.Deleted = 0; |
F |
458 |
if(row.r1){ |
|
459 |
row.Removed = 1; |
|
460 |
if(!row.Visible) this.ClearRow(row); |
|
461 |
else if(this.HideRow(row,1,null,1)==-1) return; |
|
462 |
row.Removed = 0; |
|
463 |
} |
|
464 |
if(row.parentNode.Count) row.parentNode.Count--; |
|
465 |
for(var r=row.firstChild;r;) { var n = r.nextSibling; this.DelRow(r,nonested); r = n; } |
|
466 |
|
|
467 |
this.UndoStart(); |
|
468 |
|
|
469 |
MS.RowSpan; |
|
470 |
if(row.RowSpan) { |
|
471 |
var O = {}, U = null, oldprev = row.previousSibling; |
|
472 |
if(this.Undo&1&&this.OUndo){ U = this.GetUndoSpan(O); if(oldprev) U.UpdateRowSpan[oldprev.id] = 1; } |
|
473 |
for(var col in this.SpanCols) if(row[col+"RowSpan"]>1) this.SplitSpanned(row,col); |
|
474 |
this.RemoveRowSpan([row],O,U); if(U) this.AddUndo({ Type:"RemoveSpan",Data:U }); |
|
475 |
for(var ro in O) this.RefreshRow(O[ro]); |
|
476 |
} |
|
477 |
ME.RowSpan; |
|
478 |
|
|
479 |
MS.Master; |
|
480 |
if(row.DetailRow) for(var i=0;i<row.DetailRow.length;i++){ |
|
481 |
if(!row.DetailRow[i].Page) row.DetailGrid[i].DelRow(row.DetailRow[i]); |
|
482 |
else if(!nonested) this.RefreshDetail(row.DetailGrid[i],1); |
|
483 |
else continue; |
|
484 |
i--; |
|
485 |
if(!row.DetailRow) break; |
|
486 |
} |
|
487 |
if(row.MasterRow) this.DelDetail(row); |
|
488 |
ME.Master; |
|
489 |
|
|
490 |
MS.Gantt; |
|
491 |
if(this.Gantt){ |
|
492 |
var C = this.Cols[this.GetFirstGantt()]; |
|
493 |
if(C && C.GanttRunSelect && C.Sel[row.id]) delete C.Sel[row.id]; |
|
494 |
} |
|
495 |
ME.Gantt; |
|
496 |
MS.Undo; if(this.Undo) { var n = row.parentNode.Page ? this.GetNextSibling(row) : row.nextSibling, p = row.parentNode; this.AddUndo({Type:"Remove",Row:row,NextId:n?n.id:null,ParentId:p.id,Page:p.Page,Removed:1}); } ME.Undo; |
|
497 |
if(this.SetIds) delete this.Rows[row.id]; |
|
498 |
row.parentNode.removeChild(row); |
|
499 |
MS.RowSpan; if(row.RowSpan && oldprev) this.UpdateRowSpan(oldprev,1); ME.RowSpan; |
|
500 |
this.UndoEnd(); this.MergeUndo(); |
|
501 |
row.Removed = 1; |
|
502 |
this.LoadedCount--; |
|
503 |
} |
|
504 |
TGP.RemoveRow = TGP.DelRow; |
|
505 |
ME.Show; |
|
506 |
// ----------------------------------------------------------------------------------------------------------- |