This is a migrated thread and some comments may be shown as answers.

Filter on Uint32 datasource field

3 Answers 93 Views
MultiColumn ComboBox
This is a migrated thread and some comments may be shown as answers.
Alex latty
Top achievements
Rank 1
Alex latty asked on 03 Mar 2010, 09:46 AM
I have a dataset witha datatable which contains a field called "PersonID" which is type UInt32. I want to duplicate the filter example in your demo application so amended the code to suit my fields, as shown below. I also set the DisplayMember to "PersonID".

            GridViewTextBoxColumn column = new GridViewTextBoxColumn("PersonID");
            column.HeaderText = "Person";
            column.IsPinned = true;
            multiColumnComboElement.Columns.Add(column);

I added your filter code

            FilterExpression filter = new FilterExpression(this.radMultiColumnComboBoxFind.DisplayMember,
                                          FilterExpression.BinaryOperation.AND,
                                          GridKnownFunction.StartsWith, GridFilterCellElement.ParameterName);
            filter.Parameters.Add(GridFilterCellElement.ParameterName, string.Empty);

            this.radMultiColumnComboBoxFind.EditorControl.MasterGridViewTemplate.FilterExpressions.Add(filter);
            this.radMultiColumnComboBoxFind.MultiColumnComboBoxElement.AutoCompleteMode = AutoCompleteMode.None;
            this.radMultiColumnComboBoxFind.DropDownStyle = RadDropDownStyle.DropDown;

I keep getting the error "Cannot perform 'Like' operation on System.UInt32 and System.String.". I guess it's something to do with the column being string and the underlying data Unit32. I don't want to change the datatype in the datatable to a string. Is there anyway to get this working. Many thanks in advance.

Alex



3 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 08 Mar 2010, 08:54 AM
Hi Alex latty,

Thank you for writing. Most probably you have experienced the described exception because you are using StartsWith function which is not compatible with any integer values. Please, try to use EqualTo instead and let me know if you still experience any issues.

All the best,
Martin Vasilev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Alex latty
Top achievements
Rank 1
answered on 08 Mar 2010, 07:26 PM
Mrtin

Thanks for that. Tried replace the StartsWith with EqualTo and now I get the error

"Cannot perform '=' operation on System.UInt32 and System.String.

looks like its solved one problem and created another. Any other ideas. Do I need to change something else. Here is the code as of now

              // Filtering START  
                FilterExpression filter = new FilterExpression(this.radMultiColumnComboBoxFind.DisplayMember,
                                              FilterExpression.BinaryOperation.AND,
                                              GridKnownFunction.EqualTo, GridFilterCellElement.ParameterName);
                filter.Parameters.Add(GridFilterCellElement.ParameterName, string.Empty);

                this.radMultiColumnComboBoxFind.EditorControl.MasterGridViewTemplate.FilterExpressions.Add(filter);
                this.radMultiColumnComboBoxFind.MultiColumnComboBoxElement.AutoCompleteMode = AutoCompleteMode.None;
                this.radMultiColumnComboBoxFind.DropDownStyle = RadDropDownStyle.DropDown;
                // Filtering END 




Any help appreciated.

Alex
0
Martin Vasilev
Telerik team
answered on 12 Mar 2010, 08:40 AM
Hello Alex latty,

Thank you for getting back to me. Actually, after further investigation, I determined that there is no straightforward way to use the AutoFilter functionality on a column which does not contain text data. However, I can suggest using CustomFiltering to accomplish such a requirement. Please, consider the following code:

void SetUpCustomFiltering()
        {
            //.......
            this.radMultiColumnComboBox1.DisplayMember = "Uint_Value";
            this.radMultiColumnComboBox1.AutoFilter = true;
  
            radMultiColumnComboBox1.EditorControl.CustomFiltering += new GridViewCustomFilteringEventHandler(EditorControl_CustomFiltering);
            radMultiColumnComboBox1.EditorControl.Columns["Uint_Value"].CustomDataOperation = CustomDataOperation.Filtering;
            radMultiColumnComboBox1.EditorControl.EnableFiltering = true;
            radMultiColumnComboBox1.EditorControl.MasterGridViewTemplate.ShowFilteringRow = false;
            radMultiColumnComboBox1.TextChanged += new EventHandler(combo_TextChanged);
        }
  
        void combo_TextChanged(object sender, EventArgs e)
        {
            RadMultiColumnComboBox combo = (RadMultiColumnComboBox)sender;
            combo.EditorControl.Columns["Uint_Value"].Filter = null;
            combo.EditorControl.Columns["Uint_Value"].Filter = 
                new FilterExpression(FilterExpression.BinaryOperation.AND, GridKnownFunction.EqualTo, "justForceFilteringEvent");
        }
  
        void EditorControl_CustomFiltering(object sender, GridViewCustomFilteringEventArgs e)
        {
            if (string.IsNullOrEmpty(radMultiColumnComboBox1.Text))
            {
                e.Visible = true;
            }
            else
            {
                e.Visible = e.GridViewTemplate.Rows[e.RowIndex].Cells[e.Column.UniqueName].Value.ToString() == radMultiColumnComboBox1.Text;
            }
        }

Do not hesitate to contact me again if you have other questions.

All the best,
Martin Vasilev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
MultiColumn ComboBox
Asked by
Alex latty
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Alex latty
Top achievements
Rank 1
Share this question
or