public void ModifyInstanceGridView(XpandXafGridView masterGridView, int rowHandle, int relationIndex, IModelListView masterModelListView, List<IMasterDetailRule> masterDetailRules) { var modelDetailRelationCalculator = new ModelDetailRelationCalculator(masterModelListView, masterGridView, masterDetailRules); bool isRelationSet = modelDetailRelationCalculator.IsRelationSet(rowHandle, relationIndex); if (isRelationSet) { IModelListView childModelListView = modelDetailRelationCalculator.GetChildModelListView(rowHandle, relationIndex); Window window = _xafApplication.CreateWindow(TemplateContext.View, null, true, false); ListView listView = GetListView(modelDetailRelationCalculator, rowHandle, relationIndex, childModelListView); var detailXafGridView = (XpandXafGridView)masterGridView.GetDetailView(rowHandle, relationIndex); ((XpandGridListEditor)listView.Editor).CustomGridViewCreate += (o, eventArgs) => { eventArgs.Handled = true; eventArgs.GridView = detailXafGridView; eventArgs.GridControl.DataSource = detailXafGridView.DataSource; }; EventHandler[] listViewOnControlsCreated = { null }; listViewOnControlsCreated[0] = (sender, args) => { detailXafGridView.MasterFrame = masterGridView.MasterFrame ?? _masterFrame; detailXafGridView.Window = window; detailXafGridView.GridControl = masterGridView.GridControl; listView.ControlsCreated -= listViewOnControlsCreated[0]; }; listView.ControlsCreated += listViewOnControlsCreated[0]; ((PropertyCollectionSource)listView.CollectionSource).MasterObject = masterGridView.GetRow(rowHandle); window.SetView(listView); } }
public void ModifyInstanceGridView(XpandXafGridView masterGridView, int rowHandle, int relationIndex, IModelListView masterModelListView, List <IMasterDetailRule> masterDetailRules) { var modelDetailRelationCalculator = new ModelDetailRelationCalculator(masterModelListView, masterGridView, masterDetailRules); bool isRelationSet = modelDetailRelationCalculator.IsRelationSet(rowHandle, relationIndex); if (isRelationSet) { IModelListView childModelListView = modelDetailRelationCalculator.GetChildModelListView(rowHandle, relationIndex); Window window = _xafApplication.CreateWindow(TemplateContext.View, null, true, false); ListView listView = GetListView(modelDetailRelationCalculator, rowHandle, relationIndex, childModelListView); var detailXafGridView = (XpandXafGridView)masterGridView.GetDetailView(rowHandle, relationIndex); ((XpandGridListEditor)listView.Editor).CustomGridViewCreate += (o, eventArgs) => { ((XpandGridListEditor)o).DataSource = detailXafGridView.DataSource; eventArgs.Handled = true; eventArgs.GridView = detailXafGridView; eventArgs.GridControl.DataSource = detailXafGridView.DataSource; }; EventHandler[] listViewOnControlsCreated = { null }; listViewOnControlsCreated[0] = (sender, args) => { detailXafGridView.MasterFrame = masterGridView.MasterFrame ?? _masterFrame; detailXafGridView.Window = window; detailXafGridView.GridControl = masterGridView.GridControl; listView.ControlsCreated -= listViewOnControlsCreated[0]; }; listView.ControlsCreated += listViewOnControlsCreated[0]; ((PropertyCollectionSource)listView.CollectionSource).MasterObject = masterGridView.GetRow(rowHandle); window.SetView(listView); } }
void ViewOnMasterRowEmpty(object sender, MasterRowEmptyEventArgs e) { if (View.Id != "MasterDetailAtAnyLevelCustomer_ListView") { Debug.Print(""); } if (e.RelationIndex > -1) { var modelDetailRelationCalculator = new ModelDetailRelationCalculator(View.Model, (XpandXafGridView)sender, MasterDetailRules); e.IsEmpty = !modelDetailRelationCalculator.IsRelationSet(e.RowHandle, e.RelationIndex); } }
XpandXafGridView GetLevelDefaultViewCore(IModelListView masterModelListView, XpandXafGridView masterGridView, int rowHandle, int relationIndex, List<IMasterDetailRule> masterDetailRules) { var modelDetailRelationCalculator = new ModelDetailRelationCalculator(masterModelListView, masterGridView, masterDetailRules); bool isRelationSet = modelDetailRelationCalculator.IsRelationSet(rowHandle, relationIndex); if (isRelationSet) { IModelListView childModelListView = modelDetailRelationCalculator.GetChildModelListView(rowHandle, relationIndex); ListView listView = GetListView(modelDetailRelationCalculator, rowHandle, relationIndex, childModelListView); XpandXafGridView defaultXpandXafGridView = null; EventHandler[] listViewOnControlsCreated = { null }; listViewOnControlsCreated[0] = (sender, args) => { defaultXpandXafGridView = (XpandXafGridView)((GridListEditor)((XpandListView)sender).Editor).GridView; listView.ControlsCreated -= listViewOnControlsCreated[0]; }; listView.ControlsCreated += listViewOnControlsCreated[0]; listView.CreateControls(); return defaultXpandXafGridView; } return null; }
XpandXafGridView GetLevelDefaultViewCore(IModelListView masterModelListView, XpandXafGridView masterGridView, int rowHandle, int relationIndex, List <IMasterDetailRule> masterDetailRules) { var modelDetailRelationCalculator = new ModelDetailRelationCalculator(masterModelListView, masterGridView, masterDetailRules); bool isRelationSet = modelDetailRelationCalculator.IsRelationSet(rowHandle, relationIndex); if (isRelationSet) { IModelListView childModelListView = modelDetailRelationCalculator.GetChildModelListView(rowHandle, relationIndex); ListView listView = GetListView(modelDetailRelationCalculator, rowHandle, relationIndex, childModelListView); XpandXafGridView defaultXpandXafGridView = null; EventHandler[] listViewOnControlsCreated = { null }; listViewOnControlsCreated[0] = (sender, args) => { defaultXpandXafGridView = (XpandXafGridView)((GridListEditor)((XpandListView)sender).Editor).GridView; listView.ControlsCreated -= listViewOnControlsCreated[0]; }; listView.ControlsCreated += listViewOnControlsCreated[0]; listView.CreateControls(); return(defaultXpandXafGridView); } return(null); }
void ViewOnMasterRowEmpty(object sender, MasterRowEmptyEventArgs e) { if (e.RelationIndex > -1) { var modelDetailRelationCalculator = new ModelDetailRelationCalculator(View.Model, (IMasterDetailXafGridView)sender, RequestRules.Invoke(Frame)); e.IsEmpty = !modelDetailRelationCalculator.IsRelationSet(e.RowHandle, e.RelationIndex); } }