protected void SetViewFrom(BindingListSource sourceBindingList, IRowSource newRowSource, BindingListSource targetBindingList) { targetBindingList.SetView(sourceBindingList.ViewInfo, newRowSource); targetBindingList.RowFilter = sourceBindingList.RowFilter; if (sourceBindingList.SortDescriptions != null) { targetBindingList.ApplySort(sourceBindingList.SortDescriptions); } }
public void TestDataBindingIsSulfur() { var dataSchema = new DataSchema(); var viewSpec = new ViewSpec().SetColumns(new[] { new ColumnSpec(PropertyPath.Parse("Code")), new ColumnSpec(PropertyPath.Parse("Molecule!*.Key")), }) .SetFilters(new[] { new FilterSpec(PropertyPath.Parse("Molecule!*.Key"), FilterPredicate.CreateFilterPredicate(dataSchema, typeof(string), FilterOperations.OP_EQUALS, "S")) }); var bindingListSource = new BindingListSource(); bindingListSource.SetView(new ViewInfo(dataSchema, typeof(AminoAcid), viewSpec), AminoAcid.AMINO_ACIDS); Assert.AreEqual(2, bindingListSource.Count); }
public void TestDataBindingIsNotNullFilter() { var dataSchema = new DataSchema(); var viewSpec = new ViewSpec().SetColumns(new[] { new ColumnSpec(PropertyPath.Parse("AminoAcidsDict!*.Value")), }) .SetSublistId(PropertyPath.Parse("AminoAcidsDict!*")); var viewSpecWithFilter = viewSpec.SetFilters(new[] { new FilterSpec(PropertyPath.Parse("AminoAcidsDict!*.Value"), FilterPredicate.IS_NOT_BLANK), }); var bindingListSource = new BindingListSource(); var bindingListSourceWithFilter = new BindingListSource(); bindingListSource.SetView(new ViewInfo(dataSchema, typeof(Peptide), viewSpec), null); bindingListSourceWithFilter.SetView(new ViewInfo(dataSchema, typeof(Peptide), viewSpecWithFilter), new[] { new Peptide("") }); Assert.AreEqual(0, bindingListSourceWithFilter.Count); bindingListSource.RowSource = bindingListSourceWithFilter.RowSource; Assert.AreEqual(1, bindingListSource.Count); }
private void UpdateViewContext() { var documentGridViewContext = BindingListSource.ViewContext as DocumentGridViewContext; if (documentGridViewContext == null) { return; } documentGridViewContext.UpdateBuiltInViews(); if (null != BindingListSource.ViewInfo && null != BindingListSource.ViewInfo.ViewGroup && ViewGroup.BUILT_IN.Id.Equals(BindingListSource.ViewInfo.ViewGroup.Id)) { var viewName = BindingListSource.ViewInfo.ViewGroup.Id.ViewName(BindingListSource.ViewInfo.Name); var newViewInfo = documentGridViewContext.GetViewInfo(viewName); if (null != newViewInfo && !Equals(newViewInfo.ViewSpec, BindingListSource.ViewSpec)) { BindingListSource.SetView(newViewInfo, BindingListSource.RowSource); } } }