private void btnAscending_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     FilterEventArgs args = new FilterEventArgs();
     args.FilterType = FilterEventArgs.FilterTypes.Sort;
     args.Ascending = true;
     if (FilterChanged != null)
         FilterChanged(this, args);
 }
Exemple #2
0
        public void FilterColumn(ExcelColumn sortColumn, FilterEventArgs.FilterTypes filterType, bool ascending, string value)
        {
            CurrentColumnSort = sortColumn;
            // If there's no current filter data, its the main dataset
            if (CurrentFilterData == null)
                CurrentFilterData = ExcelParams.ItemsSource;

            // If there was a last sort column, set it to non.
            if (LastColumnSort != null)
                LastColumnSort.Control.OrderBy = CellHeaderControl.OrderBys.None;

            IEnumerable<Dictionary<string, object>> filtered = null;

            // If its a sort..
            if (filterType == FilterEventArgs.FilterTypes.Sort)
            {

                // if its ascending, do an orderby ascending
                if (ascending)
                {
                    filtered = from x in CurrentFilterData
                               orderby x[CurrentColumnSort.PropertyBind] ascending
                               select x;
                    CurrentColumnSort.Control.OrderBy = CellHeaderControl.OrderBys.Ascending;
                }
                else
                {
                    filtered = from x in CurrentFilterData
                               orderby x[CurrentColumnSort.PropertyBind] descending
                               select x;
                    CurrentColumnSort.Control.OrderBy = CellHeaderControl.OrderBys.Descending;

                }
            }
            else
            { // otherwise filter by the value
                if (value == GridConstants.All)
                    CurrentColumnSort.Control.Filtered = false;
                else
                    CurrentColumnSort.Control.Filtered = true;

                CurrentColumnSort.CurrentFilter = value;
                filtered = ExcelParams.ItemsSource;

                // As it's would be complicated to remember all the other filters on columns, just use the
                // full dataset again and build each filter in if the CurrentFilter on the column is not empty.
                foreach (string key in ExcelParams.Columns.Keys)
                {
                    ExcelColumn column = ExcelParams.Columns[key];
                    Cell builderCell = CellBuilder.BuildCell(column.Index, column, null);
                    filtered = builderCell.Filter(filtered);
                    
                    /*if (!string.IsNullOrEmpty(column.CurrentFilter))
                    {

                        filtered = from x in filtered
                                   where (x[column.PropertyBind] == null ? "" : x[column.PropertyBind].ToString()).Contains(column.CurrentFilter)
                                   select x;
                    }*/

                }
            }

            CurrentFilterData = filtered;

            ExcelParams.PopulateData(CurrentFilterData.ToList<Dictionary<string, object>>());

        }
Exemple #3
0
 void filterControl_FilterChanged(object sender, FilterEventArgs e)
 {
     FilterColumn(((FilterControl)sender).excelColumn, e.FilterType, e.Ascending, e.Value);
     HideFilter();
 }
 void item_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     FilterEventArgs args = new FilterEventArgs();
     args.FilterType = FilterEventArgs.FilterTypes.Filter;
     args.Value = ((FilterItem)sender).txtTitle.Text;
     if (FilterChanged != null)
         FilterChanged(this, args);
 }