public void AddOrderByOption(string propertyPath, bool isAscending) { OrderOptions.Add(new OrderByExpression.OrderOption() { PropertyPath = propertyPath, IsAscending = isAscending }); }
public void OnLoaded() { if (loaded) { return; } loaded = true; if (FilterColumn.HasText()) { FilterOptions.Add(new FilterOption { ColumnName = FilterColumn, Operation = FilterOperation.EqualTo, Frozen = true, }.Bind(FilterOption.ValueProperty, new Binding("DataContext" + (FilterRoute.HasText() ? "." + FilterRoute : null)) { Source = this })); if (QueryUtils.IsColumnToken(FilterColumn)) { ColumnOptions.Add(new ColumnOption(FilterColumn)); ColumnOptionsMode = ColumnOptionsMode.Remove; } if (this.NotSet(SearchOnLoadProperty)) { SearchOnLoad = true; } } if (OrderOptions.IsNullOrEmpty() && !entityColumn.Implementations.Value.IsByAll) { var orderType = entityColumn.Implementations.Value.Types.All(t => EntityKindCache.GetEntityData(t) == EntityData.Master) ? OrderType.Ascending : OrderType.Descending; var column = Description.Columns.SingleOrDefaultEx(c => c.Name == "Id"); if (column != null) { OrderOptions.Add(new OrderOption(column.Name, orderType)); } } btCreate.ToolTip = SearchMessage.CreateNew0_G.NiceToString() .ForGenderAndNumber(entityColumn.Implementations.Value.Types.FirstOrDefault()?.GetGender() ?? 'm') .FormatWith(entityColumn.Implementations.Value.Types.CommaOr(a => a.NiceName())); if (this.NotSet(SearchControl.NavigateProperty) && Navigate) { Navigate = Implementations.IsByAll ? true : Implementations.Types.Any(t => Navigator.IsNavigable(t, isSearch: true)); } if (this.NotSet(EntityBase.CreateProperty) && Create) { Create = Implementations.IsByAll ? false : Implementations.Types.Any(t => Navigator.IsCreable(t, isSearch: true)); } ColumnOption.SetColumnTokens(ColumnOptions, Description); if (this.CanAddFilters || this.AllowChangeColumns) { headerContextMenu = new ContextMenu(); if (this.CanAddFilters) { headerContextMenu.Items.Add(new MenuItem { Header = SearchMessage.AddFilter.NiceToString() }.Handle(MenuItem.ClickEvent, filterHeader_Click)); } if (this.CanAddFilters && this.AllowChangeColumns) { headerContextMenu.Items.Add(new Separator()); } if (this.AllowChangeColumns) { headerContextMenu.Items.Add(new MenuItem { Header = SearchMessage.Rename.NiceToString() }.Handle(MenuItem.ClickEvent, renameMenu_Click)); headerContextMenu.Items.Add(new MenuItem { Header = EntityControlMessage.Remove.NiceToString() }.Handle(MenuItem.ClickEvent, removeMenu_Click)); } } GenerateListViewColumns(); FilterOption.SetFilterTokens(FilterOptions, Description); filterBuilder.Filters = FilterOptions; ((INotifyCollectionChanged)FilterOptions).CollectionChanged += FilterOptions_CollectionChanged; OrderOption.SetOrderTokens(OrderOptions, Description); SortGridViewColumnHeader.SetColumnAdorners(gvResults, OrderOptions); if (IsVisible) { FillMenuItems(); if (SearchOnLoad) { Search(); } } else { IsVisibleChanged += SearchControl_IsVisibleChanged; } UpdateVisibility(); AutomationProperties.SetName(this, QueryUtils.GetKey(QueryName)); foreach (var item in FilterOptions) { item.BindingValueChanged += new DependencyPropertyChangedEventHandler(item_BindingValueChanged); } }