コード例 #1
0
        public static string GetTextFromState(C1.Silverlight.DataGrid.DataGridColumn column)
        {
            string text = "";

            if (column.FilterState != null &&
                column.FilterState.FilterInfo != null &&
                column.FilterState.FilterInfo.Count > 0)
            {
                if (column is DataGridComboBoxColumn)
                {
                    if (column.FilterState.Tag is string)
                    {
                        text = column.FilterState.Tag.ToString();
                    }
                }
                else
                {
                    if (column.FilterState.FilterInfo[0].FilterOperation == FilterOperation.Contains)
                    {
                        text = column.FilterState.FilterInfo[0].Value.ToString();
                    }
                }
            }
            return(text);
        }
コード例 #2
0
        // *******************************************************************
        // Column's type specific filter logic
        // *******************************************************************
        public static DataGridFilterState BuildFilterState(C1.Silverlight.DataGrid.DataGridColumn column, string text)
        {
            var fs = new DataGridFilterState();

            fs.FilterInfo = new List <FilterInfo>();
            fs.Tag        = text;

            // check if there is text to filter
            if (text == string.Empty)
            {
                return(null);
            }

            if (column is DataGridComboBoxColumn)
            {
                // We need special handling for combo columns
                // because diplayed text is different than the value in the datasource (id)
                // We need to define the "Contains" operator taking ids into account
                fs.FilterInfo.Add(new FilterInfo()
                {
                    Value           = GetIdsContainingText(text, column as DataGridComboBoxColumn),
                    FilterOperation = FilterOperation.IsOneOf,
                });
            }
            else
            {
                // Contains for text columns
                fs.FilterInfo.Add(new FilterInfo()
                {
                    FilterType      = FilterType.Text,
                    Value           = text,
                    FilterOperation = FilterOperation.Contains,
                });
            }
            return(fs);
        }