internal void OnAppearing() { Patients = PatientListService.GetPatients(); foreach (var p in Patients) { p.TopLeftGroup = new ObservableCollection <DynamicValue>(); p.TopRightGroup = new ObservableCollection <DynamicValue>(); p.LeftGroup = new ObservableCollection <DynamicValue>(); p.RightGroup = new ObservableCollection <DynamicValue>(); foreach (var c in ColumnGroups.FirstOrDefault(c => c.Title == "TopLeft").ToList()) { p.TopLeftGroup.Add(new DynamicValue { Header = c.Header, Value = c.Value }); } foreach (var c in ColumnGroups.FirstOrDefault(c => c.Title == "TopRight").ToList()) { p.TopRightGroup.Add(new DynamicValue { Header = c.Header, Value = c.Value }); } foreach (var c in ColumnGroups.FirstOrDefault(c => c.Title == "Left").ToList()) { p.LeftGroup.Add(new DynamicValue { Header = c.Header, Value = c.Value }); } foreach (var c in ColumnGroups.FirstOrDefault(c => c.Title == "Right").ToList()) { p.RightGroup.Add(new DynamicValue { Header = c.Header, Value = c.Value }); } } }
//If the user selects a column option. We need to perform the operation private void optionCtrl_PropertyChanged(object sender, PropertyChangedEventArgs e) { var optionCtrl = sender as ColumnOptionControl; if (e.PropertyName == "SelectedColumnOptionItem") { if (optionCtrl != null) { switch (optionCtrl.SelectedColumnOptionItem.ColumnOption) { case Enums.ColumnOption.AddGrouping: optionCtrl.IsGrouped = true; var v = new PagedCollectionView(FilteredItemsSource); var newGroup = new PropertyGroupDescription(optionCtrl.FilterColumnInfo.PropertyPath, optionCtrl.FilterColumnInfo.Converter); ColumnGroups.Add(newGroup); foreach (var item in ColumnGroups) { v.GroupDescriptions.Add(item); } ItemsSource = v; break; case Enums.ColumnOption.RemoveGrouping: optionCtrl.IsGrouped = false; var view = new PagedCollectionView(FilteredItemsSource); var group = ColumnGroups.FirstOrDefault(c => c.PropertyName == optionCtrl.FilterColumnInfo.PropertyPath); if (@group != null) { ColumnGroups.Remove(@group); } foreach (var item in ColumnGroups) { view.GroupDescriptions.Add(item); } ItemsSource = view; break; case Enums.ColumnOption.PinColumn: optionCtrl.IsPinned = true; var frozenCount = FrozenColumnCount; if (optionCtrl.Column.DisplayIndex >= FrozenColumnCount) { frozenCount++; } optionCtrl.Column.DisplayIndex = 0; FrozenColumnCount = frozenCount; break; case Enums.ColumnOption.UnpinColumn: optionCtrl.IsPinned = false; if (FrozenColumnCount == 0) { FrozenColumnCount = 1; } optionCtrl.Column.DisplayIndex = FrozenColumnCount - 1; FrozenColumnCount = FrozenColumnCount - 1; break; } } } }
/// <summary> /// Gets the cloned shema. /// </summary> /// <param name="table">The table.</param> /// <returns></returns> public static T GetClonedShema <T>(this DataTable table, bool disablePrimaryKey = true, String[] categories = null) where T : DataTable, new() { DataTable clone = table.Clone(); T output = new T(); ColumnGroups groupsOfColumns = clone.getGroupsOfColumns(); if (categories != null) { List <String> matched = new List <string>(); foreach (String c in categories) { var cg = groupsOfColumns.FirstOrDefault(x => x.name.Equals(c, StringComparison.InvariantCultureIgnoreCase)); if (cg == null) { if (clone.Columns.Contains(c)) { matched.Add(c); } } else { matched.AddRange(cg.Select(x => x.ColumnName)); } } List <DataColumn> dcdel = new List <DataColumn>(); foreach (DataColumn dc in clone.Columns) { if (!matched.Contains(dc.ColumnName)) { dcdel.Add(dc); } //String g = dc.GetGroup(); //if (!matched.Any()) //{ // if (!matched.Contains(dc.ColumnName)) // { // } //} //else //{ // if (!matched.Contains(g)) // { // dcdel.Add(dc); // } //} } foreach (DataColumn dc in dcdel) { clone.Columns.Remove(dc); } } table.ExtendedProperties.copyInto(output.ExtendedProperties); output.SetTitle(table.GetTitle()); output.SetDescription(table.GetDescription()); output.SetClassName(table.GetClassName()); output.SetClassType(table.GetClassType()); output.SetAggregationAspect(table.GetAggregationAspect()); output.SetAggregationOriginCount(table.GetAggregationOriginCount()); output.SetAdditionalInfo(table.GetAdditionalInfo()); output.SetExtraDesc(table.GetExtraDesc()); output.SetCategoryPriority(table.GetCategoryPriority()); output.SetStyleSet(table.GetStyleSet()); output.SetColumnMetaSet(table.GetColumnMetaSet()); output.SetRowMetaSet(table.GetRowMetaSet()); //output.SetClassType(table.Get) List <string> catPri = table.GetCategoryPriority(); if (disablePrimaryKey) { output.PrimaryKey = new DataColumn[0]; } foreach (DataColumn dc in clone.Columns) { dc.GetSPE(); } foreach (DataColumn dc in clone.Columns) { DataColumn dce = output.Columns.Add(dc.ColumnName); dce.SetSPE(dc.GetSPE()); } if (catPri.Any()) { output.Columns.OrderByCategoryPriority(catPri); } if (output.TableName.isNullOrEmpty()) { output.TableName = "datatable_" + imbStringGenerators.getRandomString(4); } return(output); }