public void LinkListToColumn(DevExpress.XtraEditors.SearchLookUpEdit col, Type tableType, string gridFilterString = "") { try { XPClassInfo classInfo = AppListSession.GetClassInfo(tableType); DataMemberXPCollection = new XPCollection(AppListSession, classInfo); col.Properties.DataSource = this.DataMemberXPCollection; RetrieveRows(false); col.Properties.View.GridControl.ForceInitialize(); SetupGridView(col.Properties.View, DataMemberXPCollection); col.Properties.ValueMember = ValueMember; col.Properties.DisplayMember = DisplayMember; if (gridFilterString != "") { col.Properties.View.ActiveFilterString = gridFilterString; } } catch (Exception ex) { XtraMessageBox.Show(ex.GetFullExceptionErrMessage()); } }
public void LinkListToColumn(DevExpress.XtraEditors.LookUpEdit col, Type _targetObj) { try { CriteriaOperator criteria = new BinaryOperator(new OperandProperty("ObjectName"), new OperandValue(_targetObj.FullName), BinaryOperatorType.Equal); var targetObjectBase = AppListSession.FindObject <UIObjectBase>(criteria); if (targetObjectBase == null) { return; } DataMemberXPCollection = new XPCollection(AppListSession, _targetObj); foreach (var labl in targetObjectBase.ObjectLabels.Where(x => x.LookupMember != CoreLib.MyEnums.AutoLookUp.None)) { if (labl.LookupMember == CoreLib.MyEnums.AutoLookUp.ValueMemberVisiable || labl.LookupMember == CoreLib.MyEnums.AutoLookUp.ValueMemberHidden) { ValueMember = labl.ColumnName; } else if (labl.LookupMember == CoreLib.MyEnums.AutoLookUp.DisplayMember1) { DisplayMember = labl.ColumnName; } col.Properties.Columns.Add(new LookUpColumnInfo(labl.ColumnName, labl.GetGUIWidth(col.Font), labl.ChooseValueForCurrentLang(CoreLib.MyEnums.UILabelType.FieldCaption))); } col.Properties.DataSource = DataMemberXPCollection; col.Properties.DisplayMember = this.DisplayMember; col.Properties.ValueMember = this.ValueMember; RetrieveRows(false); } catch (Exception ex) { XtraMessageBox.Show(ex.GetFullExceptionErrMessage()); } }
public void LinkListToColumn(DevExpress.XtraGrid.Columns.GridColumn col, Type tableType, string _valueMember = "", string gridFilterString = "") { XPClassInfo classInfo = AppListSession.GetClassInfo(tableType); DataMemberXPCollection = new XPCollection(AppListSession, classInfo); var lookupGrd = new RepositoryItemSearchLookUpEdit(); var lookupGrdView = new GridView(); lookupGrd.BeginInit(); lookupGrdView.BeginInit(); SetupGridView(lookupGrdView, DataMemberXPCollection); lookupGrd.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo) }); lookupGrd.Name = "lookupGrd"; lookupGrd.View = lookupGrdView; lookupGrd.DataSource = DataMemberXPCollection; lookupGrd.DisplayMember = DisplayMember; lookupGrd.ValueMember = string.IsNullOrEmpty(_valueMember) ? ValueMember : _valueMember; //if (_valueMember.IsNotNull()) lookupGrd.KeyMember = _valueMember; col.ColumnEdit = lookupGrd; ActiveColumnLinks.Add(col); RetrieveRows(false); //Tell AppList to get its rows if it the first use }
public void LinkToDataLayout(DataLayoutControl _dataLayout, XPCollection ds) { XPClassInfo _classInfo = ds.ObjectClassInfo; var objectBaseLine = AppListSession.FindObject <UIObjectBase>(CriteriaOperator.Parse("[ObjectName] = ? ", _classInfo.FullName)); if (objectBaseLine == null) { return; } var ControlList = GetControlList(_dataLayout, objectBaseLine); foreach (var c in ControlList) { //Get Label c.Item.Text = c.FieldSettings.ChooseValueForCurrentLang(CoreLib.MyEnums.UILabelType.FieldCaption); c.Item.OptionsToolTip.ToolTip = c.FieldSettings.ChooseValueForCurrentLang(CoreLib.MyEnums.UILabelType.FieldHelp); c.Item.Control.Enabled = !c.FieldSettings.IsDisabled; if (c.FieldSettings.LookupEditor != null) { if (c.Item.Control is LookUpEdit) { LinkListToColumn((LookUpEdit)c.Item.Control, c.FieldSettings.LookupEditor.ObjectType()); } else if (c.Item.Control is SearchLookUpEdit) { LinkListToColumn((SearchLookUpEdit)c.Item.Control, c.FieldSettings.LookupEditor.ObjectType()); } } } }
public void LinkLookupsToGrid(CoreLib.Grid.MyGridView _gridView, XPClassInfo _classInfo) { var objectBaseLine = AppListSession.FindObject <UIObjectBase>(CriteriaOperator.Parse("[ObjectName] = ? ", _classInfo.FullName)); if (objectBaseLine == null) { return; } foreach (var m in _classInfo.Members.Where(x => !string.IsNullOrEmpty(x.MappingField) || x.FindAttributeInfo("NonPersistentAttribute") == null)) { //if (x.FindAttributeInfo("NonPersistentAttribute") == null) continue; var c = _gridView.Columns.ColumnByFieldName(m.Name) == null? _gridView.Columns.ColumnByFieldName($"{m.Name}!Key") : null; if (c != null) { string fieldName = $"{m.Owner.FullName}.{m.Name}"; var labelLine = objectBaseLine.FindOrCreateUILabel(fieldName); if (labelLine != null && labelLine.LookupEditor != null) { Assembly a = CoreLib.GlobalMethods.GetAssemblyByName(objectBaseLine.AssemblyName); //Type lookupClass = a.GetType(objectBaseLine.ObjectName); Type lookupClass = a.GetType(labelLine.LookupEditor.ObjectName); LinkListToColumn(c, lookupClass); } } } }
public void SetupGridView(DevExpress.XtraGrid.Views.Grid.GridView targetGV, XPBaseCollection _listXPC) { //DevExpress.XtraGrid.Views.Grid.GridView targetGV = col.Properties.View; if (targetGV.GridControl != null) { targetGV.GridControl.ForceInitialize(); } targetGV.Columns.Clear(); targetGV.OptionsView.ColumnAutoWidth = false; targetGV.OptionsView.ShowAutoFilterRow = true; targetGV.OptionsView.ShowFooter = true; targetGV.OptionsView.ShowGroupPanel = false; targetGV.OptionsView.EnableAppearanceOddRow = true; targetGV.OptionsView.ShowFilterPanelMode = DevExpress.XtraGrid.Views.Base.ShowFilterPanelMode.ShowAlways; var classInfo = _listXPC.GetObjectClassInfo(); var objName = AppListSession.FindObject <UIObjectBase>(CriteriaOperator.Parse("[ObjectName] = ? ", classInfo.FullName)); var labels = objName.ObjectLabels.Where(x => x.LookupMember != CoreLib.MyEnums.AutoLookUp.None); foreach (var item in labels) { string filedName = item.FieldName.Substring(item.FieldName.LastIndexOf('.') + 1); string caption = item.ChooseValueForCurrentLang(CoreLib.MyEnums.UILabelType.FieldCaption); var grdCol = targetGV.Columns.AddVisible(filedName, caption); //Calc estimated width according to LookUp char width Size columnSize = TextRenderer.MeasureText("".PadLeft(item.LookupMemberCharWidth, 'A'), targetGV.Appearance.HeaderPanel.Font); grdCol.Width = columnSize.Width; if (item.LookupMember == CoreLib.MyEnums.AutoLookUp.ValueMemberVisiable || item.LookupMember == CoreLib.MyEnums.AutoLookUp.ValueMemberHidden) { ValueMember = filedName; } if (item.LookupMember == CoreLib.MyEnums.AutoLookUp.DisplayMember1) { DisplayMember = filedName; } } }
public void LinkLookupsToGrid(CoreLib.Grid.MyGridView _gridView, Type _type) { XPClassInfo _classInfo = AppListSession.GetClassInfo(_type); LinkLookupsToGrid(_gridView, _classInfo); }