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

RadGridView Filter boxes access

3 Answers 166 Views
GridView
This is a migrated thread and some comments may be shown as answers.
miguel
Top achievements
Rank 1
miguel asked on 12 Dec 2007, 08:05 AM
Hi,

I'm trying to gain access to the RadGridView Filter boxes contents programmaticaly. I.E. when the user enter text in the filter boxes directly underneath the column heading I want to be able to access that text programmaticaly.

I've tried the following:

foreach(GridViewCellInfo cellInfo in myRadGridView.MasterGridViewInfo.TableFilteringRow.Cells)
{
       if(cellInfo.Value != null)
           MessageBox.Show(cell.Value.ToString());
}

Values are always null

Thanks!

Miguel de Sousa
    

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 12 Dec 2007, 03:24 PM
Hello miguel,

Thank you for writing us.

In order to get access to the filter editors, please use the following code snippet:

foreach (GridViewCellInfo cell in this.radGridView1.MasterGridViewInfo.TableFilteringRow.Cells) 
    RadTextBoxItem textBox = (RadTextBoxItem)cell.CellElement.Children[1]; 
    textBox.TextChanged += new EventHandler(textBox_TextChanged); 
 
void textBox_TextChanged(object sender, EventArgs e) 
this.label1.Text = ((RadTextBoxItem)sender).Text; 
 

If you reorder columns, change the grouping or rebind the grid, you must subscribe again to the TextChanged event.

In the future, we plan to provide a more convenient way to access and customize editors in RadGridView. This may cause changes in our API, which will cause the provided sample with the older version to stop working.

We hope this code helps you. In case you need further assistance we will be glad to help you.

Kind regards,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Dave Hermans
Top achievements
Rank 1
answered on 05 Feb 2009, 11:37 AM
is the future now? I mean is there a way to access these values in the new version? I can't seem to find it.
0
Jack
Telerik team
answered on 05 Feb 2009, 05:31 PM
Hi Dave,

Yes, there is an easier way to access filter editors. For example, you can process the CellBeginEdit method and check whether the current cell is a GridFilterCellElement. The active editor can be accessed through the ActiveEditor property of RadGridView. Consider the following sample:

void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) 
    if (this.radGridView1.CurrentCell is GridFilterCellElement) 
    { 
        this.radGridView1.ActiveEditor.Value = "aa"
    } 


Should you have any further questions, do not hesitate to ask.

All the best,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
miguel
Top achievements
Rank 1
Answers by
Jack
Telerik team
Dave Hermans
Top achievements
Rank 1
Share this question
or