public override void OnSetLayoutInfo(SetLayoutInfoArgs e) { base.OnSetLayoutInfo(e); // 获取单据体表格的元数据及布局 string entityKey = "FEntity"; //Entity entity = _currBusinessInfo.GetEntity(entityKey); EntityAppearance entityApp = _currLayoutInfo.GetEntityAppearance(entityKey); Entity entity = entityApp.Entity; var textApp = _currLayoutInfo.GetFieldAppearance("FField"); var decimalApp = _currLayoutInfo.GetFieldAppearance("FDecimal"); for (int i = 0; i < entityData.Columns.Count; i++) { string name = "FField_" + (i + 1).ToString(); //FieldAppearance field = new FieldAppearance(); FieldAppearance field; if (i == 0) { field = (FieldAppearance)ObjectUtils.CreateCopy(textApp); } else { field = (FieldAppearance)ObjectUtils.CreateCopy(decimalApp); //添加合计列 GroupSumColumn sumColumn = new GroupSumColumn(); sumColumn.FieldKey = name; sumColumn.Precision = -1; sumColumn.SumType = 1; entity.GroupColumnInfo.AddGroupSumColumn(sumColumn); } field.Key = name; field.Caption = new LocaleValue(entityData.Columns[i].ColumnName); field.Field = _currBusinessInfo.GetField(name); field.Tabindex = i + 1; _currLayoutInfo.Add(field); } _currLayoutInfo.Remove(textApp); _currLayoutInfo.Remove(decimalApp); entityApp.Layoutinfo.Sort(); e.LayoutInfo = _currLayoutInfo; EntryGrid grid = this.View.GetControl <EntryGrid>("FEntity"); grid.SetCustomPropertyValue("AllowLayoutSetting", false); grid.CreateDyanmicList(_currLayoutInfo.GetEntityAppearance("FEntity")); this.View.SendDynamicFormAction(this.View); }
public void SetAppLayout(int top, int left, string key, string name, string type, int tableIdx) { int lcid = this.Context.UserLocale.LCID; // 基于模板字段的外观,产生出新字段的外观 FieldAppearance newFldApp = null; switch (type) { case "F8": newFldApp = (BaseDataFieldAppearance)ObjectUtils.CreateCopy(modelF8FieldApp); break; case "Text": newFldApp = (TextFieldAppearance)ObjectUtils.CreateCopy(modelTextFieldApp); break; case "Decimal": newFldApp = (DecimalFieldAppearance)ObjectUtils.CreateCopy(modelDecimalFieldApp); break; case "Assistant": newFldApp = (AssistantFieldAppearance)ObjectUtils.CreateCopy(modelAssistantFieldApp); break; default: throw new Exception("没有找到type"); } newFldApp.Key = key; newFldApp.EntityKey = "FBillHead"; newFldApp.Caption = new LocaleValue(name); newFldApp.Field = this.View.BusinessInfo.GetField(key); newFldApp.Top = new LocaleValue(top.ToString(), lcid); newFldApp.Left = new LocaleValue(left.ToString(), lcid); //newFldApp.Tabindex = modelTextFieldApp.Tabindex + tableIdx + 1; // 必须清除字段的容器属性,否则生成的控件,不能挂到指定的容器面板上 newFldApp.Container = ""; _currLayoutInfo.Add(newFldApp); // 把新字段外观,同步加入到容器面板的布局对象中 panelLayout.Add(newFldApp); }