Exemple #1
0
        /// <summary>Method to check if a filter item is already added based on the column to be filtered.
        ///     </summary>
        /// <param name="column">The column to be checked if the list is already filtering.</param>
        /// <param name="filterItem">The filter item to be checked.</param>
        /// <returns>True if a filter item for a specific column or for ALL is already in the list.
        ///     </returns>
        private bool IsAlreadyFiltering(int column, FilterItem filterItem)
        {
            // This would determine if Filter is already filtering ALL or a specified COLUMN.
            foreach (FilterItem item in filterItems)
            {
                if (column == -1 && item.GetFilterType().Equals(filterItem.GetFilterType()))
                {
                    return(true);
                }
                else
                {
                    if (item.GetColumn() == filterItem.GetColumn())
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemple #2
0
        /// <summary>Adds new filter item to the list.</summary>
        /// <remarks>
        /// Adds new filter item to the list. The filter will be used on the
        /// specified column.
        /// </remarks>
        /// <param name="column">the target column for filtering.</param>
        /// <param name="filter">the filter string.</param>
        public virtual void Set(int column, string filter)
        {
            FilterItem filterItem = new FilterItem(column == -1 ? FilterType.All : FilterType.Column, column, filter);

            if (IsAlreadyFiltering(column, filterItem))
            {
                if (TextUtils.IsEmpty(filter))
                {
                    Remove(column, filterItem);
                }
                else
                {
                    Update(column, filterItem);
                }
            }
            else
            {
                if (!TextUtils.IsEmpty(filter))
                {
                    Add(filterItem);
                }
            }
        }
Exemple #3
0
 /// <summary>Adds new filter item to the list of this class.</summary>
 /// <param name="filterItem">The filter item to be added to the list.</param>
 private void Add(FilterItem filterItem)
 {
     filterItems.Add(filterItem);
     tableView.Filter(this);
 }