void SyncSortInfo() { if (CollectionView == null) { return; } if (CollectionView.SortDescriptions != null) { CollectionView.SortDescriptions.Clear(); for (int i = 0; i < treeListControl.SortInfo.Count; i++) { GridSortInfo info = treeListControl.SortInfo[i]; CollectionView.SortDescriptions.Add(new SortDescription(info.FieldName, info.SortOrder)); } } }
/// <summary> /// Method to build grid context for the grid using deep copy. /// </summary> /// <param name="gridModelBuilderEntity">Contains all required config info for grid construction.</param> /// <param name="gridDefaultAction">The default action name for the grid.</param> /// <returns>GridContext.</returns> private GridContext BuildGridContext(GridModelBuilderEntity gridModelBuilderEntity, string gridDefaultAction) { // Build grid pager objec var gridPagerModel = new GridPagerModel(); gridPagerModel.CssClass = gridModelBuilderEntity.GridContext.GridPager.CssClass; gridPagerModel.CurrPageId = gridModelBuilderEntity.GridContext.GridPager.CurrPageId; gridPagerModel.PageSize = gridModelBuilderEntity.GridContext.GridPager.PageSize; gridPagerModel.TotalRecord = gridModelBuilderEntity.GridContext.GridPager.TotalRecord; gridPagerModel.NumberOfPagerElements = gridModelBuilderEntity.GridContext.GridPager.NumberOfPagerElements; // Build grid search info object. var gridSearchInfo = new GridSearchInfo(); gridSearchInfo.SearchAgainstCriteria = gridModelBuilderEntity.GridContext.SearchInfo.SearchAgainstCriteria; gridSearchInfo.SearchCriteriaList = new List <KeyValuePair <string, string> >(gridModelBuilderEntity.GridContext.SearchInfo.SearchCriteriaList); gridSearchInfo.SearchWithOr = gridModelBuilderEntity.GridContext.SearchInfo.SearchWithOr; gridSearchInfo.TextSearchKey = gridModelBuilderEntity.GridContext.SearchInfo.TextSearchKey; // Build grid sort info object. var gridSortInfo = new GridSortInfo(); gridSortInfo.SortOn = gridModelBuilderEntity.GridContext.SortInfo.SortOn; gridSortInfo.SortOrder = gridModelBuilderEntity.GridContext.SortInfo.SortOrder; // Build grid context var gridContext = new GridContext(); gridContext.AlternateRowCss = gridModelBuilderEntity.GridContext.AlternateRowCss; gridContext.CssClass = gridModelBuilderEntity.GridContext.CssClass; gridContext.DefaultAction = gridDefaultAction; gridContext.DisableGridSearch = gridModelBuilderEntity.GridContext.DisableGridSearch; gridContext.RowCss = gridModelBuilderEntity.GridContext.RowCss; gridContext.GridPager = gridPagerModel; gridContext.SearchInfo = gridSearchInfo; gridContext.SortInfo = gridSortInfo; return(gridContext); }
// AnimationManager PropertyChanged void AnimationManager_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "AnimationEntity") { if (animationManager.Animation != null && animationManager.Animation.ID == Guid.Empty) { return; } isFirstLoading = true; grdProduct.DataContext = animationManager; LongTaskExecutor.RaiseLongTaskEvent(this, new LongTaskEventArgs("Opening an animation", TaskStatus.InProgress, "Loading Item Groups")); cboItemGroups.ItemsSource = ItemGroupManager.Instance.GetAll(); LongTaskExecutor.RaiseLongTaskEvent(this, new LongTaskEventArgs("Opening an animation", TaskStatus.InProgress, "Loading Item Types")); cboItemTypes.ItemsSource = new ItemType[] { new ItemType() }.Union(ItemTypeManager.Instance.GetAll()); //LongTaskExecutor.RaiseLongTaskEvent(this, new LongTaskEventArgs("Opening an animation", TaskStatus.InProgress, "Loading Sales")); //SaleManager.Instance.GetAll(); LongTaskExecutor.RaiseLongTaskEvent(this, new LongTaskEventArgs("Opening an animation", TaskStatus.InProgress, "Loading Signatures")); cboSignature.ItemsSource = new Signature[] { new Signature() }.Union(SignatureManager.Instance.GetAllWithSales()); LongTaskExecutor.RaiseLongTaskEvent(this, new LongTaskEventArgs("Opening an animation", TaskStatus.InProgress, "Loading Brand/Axes")); BrandAxeManager.Instance.GetAllForAllocation(); LongTaskExecutor.RaiseLongTaskEvent(this, new LongTaskEventArgs("Opening an animation", TaskStatus.InProgress, "Loading Categories")); cboCategories.ItemsSource = new Category[] { new Category() }.Union(CategoryManager.Instance.GetAll()); if (animationManager.Animation != null && animationManager.Animation.AnimationProducts != null && animationManager.Animation.AnimationProducts.Count > 0) { animationManager.ProcurementPlan.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ProcurementPlan_CollectionChanged); } (grdProduct.View as TableView).RowUpdated -= View_RowUpdated; (grdProduct.View as TableView).RowUpdated += View_RowUpdated; if (animationManager.Animation != null) { animationManager.Animation.PropertyChanged -= Animation_PropertyChanged; animationManager.Animation.PropertyChanged += Animation_PropertyChanged; } GridSortInfo sort1 = new GridSortInfo("IDItemGroup"); GridSortInfo sort2 = new GridSortInfo("SortOrder"); grdProduct.BeginDataUpdate(); grdProduct.SortInfo.Clear(); grdProduct.SortInfo.Add(sort1); grdProduct.SortInfo.Add(sort2); grdProduct.ClearGrouping(); grdProduct.EndDataUpdate(); } else if (e.PropertyName == "ProcurementPlan") { AddRetailerTypeColumns(); } }
void ProductDetailAnimation_Loaded(object sender, RoutedEventArgs e) { if (IsVisible && bFirstTime) { double bestFitWidth = (grdProductDetails.View as TableView).CalcColumnBestFitWidth(clmProductDescription); if (bestFitWidth > 0) { clmProductDescription.Width = (grdProductDetails.View as TableView).CalcColumnBestFitWidth(clmProductDescription); } DataContext = AnimationManager.GetInstance(); grdProductDetails.Visibility = System.Windows.Visibility.Hidden; LongTaskExecutor.RaiseLongTaskEvent(this, new LongTaskEventArgs("Loading product details", TaskStatus.Started)); cboSalesArea.ItemsSource = SalesAreaManager.Instance.GetAll(); // cboProducts.ItemsSource = AnimationManager.GetInstance().Products; // grouping and collapsing grdProductDetails.BeginDataUpdate(); try { // sorting by ItemGroup, then by SortOrder grdProductDetails.ClearSorting(); GridSortInfo sort1 = new GridSortInfo(clmItemGroup.FieldName); GridSortInfo sort2 = new GridSortInfo(clmSortOrder.FieldName); grdProductDetails.SortInfo.Add(sort1); grdProductDetails.SortInfo.Add(sort2); grdProductDetails.ClearGrouping(); grdProductDetails.GroupBy(clmSalesArea); } finally { grdProductDetails.EndDataUpdate(); grdProductDetails.CollapseAllGroups(); LongTaskExecutor.RaiseLongTaskEvent(this, new LongTaskEventArgs("Loading product details", TaskStatus.Finished)); grdProductDetails.Visibility = System.Windows.Visibility.Visible; } if (animationManager.Animation != null && animationManager.Animation.Status != null) ChangeDataEntryLocking(animationManager.Animation.Status.Value); bFirstTime = false; } }