Filter on Uint32 datasource field

4 posts, 0 answers
  1. Alex latty
    Alex latty avatar
    2 posts
    Member since:
    Jan 2010

    Posted 03 Mar 2010 Link to this post

    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



  2. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 08 Mar 2010 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Alex latty
    Alex latty avatar
    2 posts
    Member since:
    Jan 2010

    Posted 08 Mar 2010 Link to this post

    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
  5. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 12 Mar 2010 Link to this post

    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.
Back to Top