예제 #1
0
        public static List <Column> MergeColumns(IEnumerable <ColumnOption> columns, ColumnOptionsMode mode, QueryDescription qd)
        {
            switch (mode)
            {
            case ColumnOptionsMode.Add:
                return(qd.Columns.Where(cd => !cd.IsEntity).Select(cd => new Column(cd, qd.QueryName)).Concat(
                           columns.Select(co => co.ToColumn())).ToList());

            case ColumnOptionsMode.Remove:
                return(qd.Columns.Where(cd => !cd.IsEntity && !columns.Any(co => co.ColumnName == cd.Name)).Select(cd => new Column(cd, qd.QueryName)).ToList());

            case ColumnOptionsMode.Replace:
                return(columns.Select(co => co.ToColumn()).ToList());

            default:
                throw new InvalidOperationException("{0} is not a valid ColumnOptionMode".FormatWith(mode));
            }
        }
예제 #2
0
        public void Reinitialize(IEnumerable <FilterOption> filters, List <ColumnOption> columns, ColumnOptionsMode columnOptionsMode, List <OrderOption> orders)
        {
            if (qd == null)
            {
                qd = DynamicQueryServer.GetQueryDescription(QueryName);
            }

            ColumnOptions.Clear();
            ColumnOptions.AddRange(columns);
            ColumnOptionsMode = columnOptionsMode;

            FilterOptions.Clear();
            FilterOptions.AddRange(filters);
            FilterOption.SetFilterTokens(FilterOptions, qd);

            OrderOptions.Clear();
            OrderOptions.AddRange(orders);
            OrderOption.SetOrderTokens(OrderOptions, qd);
        }
예제 #3
0
        public override string ToString()
        {
            if (FilterOptions.Any())
            {
                QueryDescription queryDescription = DynamicQueryManager.Current.QueryDescription(QueryName);

                FilterOption.SetFilterTokens(FilterOptions, queryDescription, canAggregate: false);
            }

            var elements = Pagination != null?Pagination.GetElementsPerPage() : null;

            string options = new Sequence <string>
            {
                Pagination != null ? "pagination=" + pagination.GetMode().ToString() : null,
                elements != null ? "elems=" + elements : null,
                SearchOnLoad ? "searchOnLoad=true" : null,
                !Create ? "create=false": null,
                !Navigate ? "navigate=false": null,
                !AllowSelection ? "allowSelection=false" : null,
                !AllowChangeColumns ? "allowChangeColumns=false" : null,
                !AllowOrder ? "allowOrder=false" : null,
                !showHeader ? "showHeader=false" : null,
                !showFilters ? "showFilters=false" : null,
                !showFilterButton ? "showFilterButton=false" : null,
                !showFooter ? "showFooter=false" : null,
                !showContextMenu ? "showContextMenu=false" : null,
                (FilterOptions != null && FilterOptions.Count > 0) ? ("filters=" + FilterOptions.ToString(";")) : null,
                (OrderOptions != null && OrderOptions.Count > 0) ? ("orders=" + OrderOptions.ToString(";")) : null,
                (ColumnOptions != null && ColumnOptions.Count > 0) ? ("columns=" + ColumnOptions.ToString(";")) : null,
                (ColumnOptionsMode != ColumnOptionsMode.Add ? ("columnMode=" + ColumnOptionsMode.ToString()) : null),
                !SelectedItemsContextMenu ? "selectedItemsContextMenu=false" : null
            }.NotNull().ToString("&");

            if (options.HasText())
            {
                return(Finder.FindRoute(QueryName) + "?" + options);
            }
            else
            {
                return(Finder.FindRoute(QueryName));
            }
        }
예제 #4
0
        public void Reinitialize(List <FilterOption> filters, List <ColumnOption> columns, ColumnOptionsMode columnOptionsMode, List <OrderOption> orders, Pagination pagination)
        {
            try
            {
                avoidPaginationChange = true;

                ColumnOptions.Clear();
                ColumnOptions.AddRange(columns);
                ColumnOption.SetColumnTokens(ColumnOptions, Description);
                ColumnOptionsMode = columnOptionsMode;
                GenerateListViewColumns();

                if (!filters.SequenceEqual(FilterOptions))
                {
                    if (SimpleFilterBuilder != null)
                    {
                        SimpleFilterBuilder = null;
                    }

                    FilterOptions.Clear();
                    FilterOption.SetFilterTokens(filters, Description);
                    FilterOptions.AddRange(filters);
                }

                OrderOptions.Clear();
                OrderOptions.AddRange(orders);
                OrderOption.SetOrderTokens(OrderOptions, Description);
                SortGridViewColumnHeader.SetColumnAdorners(gvResults, OrderOptions);

                UpdateMultiplyMessage(true);

                Pagination = pagination;
            }
            finally
            {
                avoidPaginationChange = false;
            }
        }
예제 #5
0
        public void Reinitialize(IEnumerable<FilterOption> filters, List<ColumnOption> columns, ColumnOptionsMode columnOptionsMode, List<OrderOption> orders)
        {
            if (qd == null)
                qd = DynamicQueryServer.GetQueryDescription(QueryName);

            ColumnOptions.Clear();
            ColumnOptions.AddRange(columns);
            ColumnOptionsMode = columnOptionsMode;
           
            FilterOptions.Clear();
            FilterOptions.AddRange(filters);
            DynamicQueryServer.SetFilterTokens(FilterOptions, qd);

            OrderOptions.Clear();
            OrderOptions.AddRange(orders);
            DynamicQueryServer.SetOrderTokens(OrderOptions, qd);
        }
예제 #6
0
 public static List<Column> MergeColumns(IEnumerable<ColumnOption> columns, ColumnOptionsMode mode, QueryDescription qd)
 {
     switch (mode)
     {
         case ColumnOptionsMode.Add:
             return qd.Columns.Where(cd => !cd.IsEntity).Select(cd => new Column(cd, qd.QueryName)).Concat(
                 columns.Select(co => co.ToColumn())).ToList();
         case ColumnOptionsMode.Remove:
             return qd.Columns.Where(cd => !cd.IsEntity && !columns.Any(co => co.ColumnName == cd.Name)).Select(cd => new Column(cd, qd.QueryName)).ToList();
         case ColumnOptionsMode.Replace:
             return columns.Select(co => co.ToColumn()).ToList();
         default:
             throw new InvalidOperationException("{0} is not a valid ColumnOptionMode".FormatWith(mode));
     }
 }    
예제 #7
0
        public JObject ToJS(string prefix)
        {
            JObject op = new JObject()
            {
                { "prefix", prefix }
            };

            if (FilterOptions.Any())
            {
                QueryDescription queryDescription = DynamicQueryManager.Current.QueryDescription(QueryName);

                FilterOption.SetFilterTokens(this.FilterOptions, queryDescription, false);
            }

            if (QueryName != null)
            {
                op.Add("webQueryName", Finder.ResolveWebQueryName(QueryName));
            }
            if (SearchOnLoad == true)
            {
                op.Add("searchOnLoad", true);
            }
            if (!Navigate)
            {
                op.Add("navigate", false);
            }
            if (!Create)
            {
                op.Add("create", false);
            }
            if (!AllowSelection)
            {
                op.Add("allowSelection", false);
            }
            if (!SelectedItemsContextMenu)
            {
                op.Add("selectedItemsContextMenu", false);
            }
            if (!AllowChangeColumns)
            {
                op.Add("allowChangeColumns", false);
            }
            if (!AllowOrder)
            {
                op.Add("allowOrder", false);
            }
            if (!showHeader)
            {
                op.Add("showHeader", false);
            }
            if (!showFilters)
            {
                op.Add("showFilters", false);
            }
            if (!showFilterButton)
            {
                op.Add("showFilterButton", false);
            }
            if (!showFooter)
            {
                op.Add("showFooter", false);
            }
            if (!showContextMenu)
            {
                op.Add("showContextMenu", false);
            }
            if (FilterOptions.Any())
            {
                op.Add("filters", new JArray(filterOptions.Select(f => f.ToJS())));
            }
            if (OrderOptions.Any())
            {
                op.Add("orders", new JArray(OrderOptions.Select(oo => oo.ToJS())));
            }
            if (ColumnOptions.Any())
            {
                op.Add("columns", new JArray(ColumnOptions.Select(co => co.ToJS())));
            }
            if (ColumnOptionsMode != Entities.DynamicQuery.ColumnOptionsMode.Add)
            {
                op.Add("columnMode", ColumnOptionsMode.ToString());
            }

            if (Pagination != null)
            {
                op.Add("pagination", Pagination.GetMode().ToString());
                int?elems = Pagination.GetElementsPerPage();
                if (elems != null)
                {
                    op.Add("elems", elems.Value.ToString());
                }
            }

            return(op);
        }
        public void Reinitialize(List<FilterOption> filters, List<ColumnOption> columns, ColumnOptionsMode columnOptionsMode, List<OrderOption> orders, Pagination pagination)
        {
            try
            {
                avoidPaginationChange = true;

                ColumnOptions.Clear();
                ColumnOptions.AddRange(columns);
                ColumnOption.SetColumnTokens(ColumnOptions, Description);
                ColumnOptionsMode = columnOptionsMode;
                GenerateListViewColumns();

                if (!filters.SequenceEqual(FilterOptions))
                {
                    if (SimpleFilterBuilder != null)
                        SimpleFilterBuilder = null;

                    FilterOptions.Clear();
                    FilterOption.SetFilterTokens(filters, Description);
                    FilterOptions.AddRange(filters);
                }

                OrderOptions.Clear();
                OrderOptions.AddRange(orders);
                OrderOption.SetOrderTokens(OrderOptions, Description);
                SortGridViewColumnHeader.SetColumnAdorners(gvResults, OrderOptions);

                UpdateMultiplyMessage(true);

                Pagination = pagination;
            }
            finally
            {
                avoidPaginationChange = false;
            }
        }