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

Can't change selected row after programatically changing filter

9 Answers 306 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 07 Jan 2009, 08:01 PM
I have code for a bound grid that changes a column filter based on the value of a checkbox on the form.  When the form initially loads, I am able to select a row by clicking on the grid.  After the filter is set programtically one or more times, I can no longer select a row by clicking on the grid.  The selected row stays the same.

 

 

if (showAll.CheckState != CheckState.Checked) {  
    FilterExpression _filter = new FilterExpression(FilterExpression.BinaryOperation.AND,  
    GridKnownFunction.EqualTo,  
    GridFilterCellElement.ParameterName);  
    _filter.Parameters.Add(GridFilterCellElement.ParameterName, 123);  
    Grid1.MasterGridViewTemplate.FilterExpressions.Clear();  
    Grid1.Columns["ID"].Filter = _filter;  
}  
else {  
        Grid1.MasterGridViewTemplate.FilterExpressions.Clear();  
        Grid1.Columns["ID"].Filter = null;  
}  
 

 

9 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 09 Jan 2009, 09:05 AM
Hello Eric,

As I already wrote in your ticket, we identified the issue will address it soon.

Thank you for writing.

All the best,
Jordan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Edmund Jung
Top achievements
Rank 1
answered on 12 Jan 2009, 12:06 PM
Hi Eric,

I had the same problem and found that if you change the current row programatically after you apply the filter it seems to fix the behavior. 

 

if ( grdItems.Rows.Count > 0 )   
     grdItems.CurrentRow = grdItems.Rows[0];  
 

I hope it works for you,
Tyler

 

 

 

 

 

 

 

 

0
Jack
Telerik team
answered on 12 Jan 2009, 04:45 PM
Hi Edmund,

Thank you for sharing your solution with us. The described issue will be addressed in our upcoming service pack later this month.

Greetings,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
tyler thompson
Top achievements
Rank 1
answered on 25 Jan 2009, 08:15 PM
Hi Eric,

I have downloaded the latest build (2008_3_1321) and the notes say that the issue had been fixed but I unfortunatly still had the issue.  If I create a function called FilterGrid and call it, it would allow me to navigate but if I called that function again it would lock the selection.  After playing with it for a couple of hours I believe I have found a workaround:

       private void FilterGrid(int iTeamID)  
        {  
            //suspend the update or else you see all of the items for a brief second  
            grdItems.SuspendUpdate();  
              
            //clear grid filterexpressions and call DoEvents or else it locks the selection  
            grdItems.MasterGridViewTemplate.FilterExpressions.Clear();  
            Application.DoEvents();  
 
            //create filter expression  
            FilterExpression filterExpression = new FilterExpression();  
            filterExpression.Predicates.Add(FilterExpression.BinaryOperation.AND, GridKnownFunction.EqualTo,  
                                            GridFilterCellElement.ParameterName);  
 
            filterExpression.Parameters.Add(GridFilterCellElement.ParameterName, iTeamID);  
              
            grdItems.Columns["team_id"].Filter = filterExpression;  
             
            grdItems.ResumeUpdate();  
             
        } 

I hope this helps you.
Thanks Tyler

0
Jack
Telerik team
answered on 26 Jan 2009, 06:10 PM
Hi tyler,

I was not able to reproduce the issue with our latest release - Q3 2008 SP2. Maybe it is related with some specifics in your application. Could you please open a support ticket and send us a sample application that reproduces the issue.  This way we will be able to investigate the case in details and to address the issue.

If you do not have access to the support ticketing system, please ask the purchase holder in your company to add you as a License Developer to the purchase. More on License Developers you can find here: www.telerik.com/faq

Thank you in advance for your cooperation.

Sincerely yours,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Charlie
Top achievements
Rank 1
answered on 03 Mar 2009, 12:31 AM
I'm having the same problem as the original poster. The problem only occurs for certain strings of text eg "24" or "16" and only when i use a TextBox for inputting the search text.

What i'd like to know is if you can place the cursor in the filtering row of a specific column, that way i don't need an extra textbox and the user don't have to click on the filtering row.
0
Jack
Telerik team
answered on 03 Mar 2009, 12:35 PM
Hello Charlie,

Yes, you can. You should set the CurrentColumn and CurrentRow properties and call the BeginEdit method. Here is a sample:

this.radGridView1.CurrentColumn = this.radGridView1.Columns["Name"]; 
this.radGridView1.CurrentRow = this.radGridView1.MasterGridViewInfo.TableFilteringRow; 
this.radGridView1.BeginEdit(); 
 

I hope this helps. Please send us a sample that reproduces the issue with the filtering. This way we will be able to locate and address the issue faster.

Thank you in advance for your cooperation.

Kind regards,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Howard Rothman
Top achievements
Rank 1
answered on 27 Jul 2010, 09:10 PM
Hello,

I am using unbound data in a winforms radGridView and want to filter the data in code behind.  I am using the following approach which has no effect on the data represented in the grid.  All rows are always visible.

            string[] filterParams = new string[] { "CT", "abcd" };
            FilterExpression filter = new FilterExpression();
            foreach (string filterParam in filterParams)
            {
                filter.Predicates.Add(FilterExpression.BinaryOperation.OR, GridKnownFunction.EqualTo, filterParam);
            }
            grdModality.MasterGridViewTemplate.FilterExpressions.Clear();
            this.grdModality.Columns[0].Filter = filter;
            this.grdModality.Refresh();

When I look at the filter values they appear correct:

{(([Modality] = 'CT') OR ([Modality] = 'abcd'))}
    base {Telerik.WinControls.Data.NotifyPropertyBase}: {(([Modality] = 'CT') OR ([Modality] = 'abcd'))}
    BinaryOperator: AND
    FieldName: "Modality"
    IsApplicable: true
    IsValid: true
    Parameters: Count = 0
    Predicates: Count = 2

I tried a couple other approaches that I read online and none work.  Can you please explain what I'm doing wrong?

Thanks,
Howard
0
Julian Benkov
Telerik team
answered on 30 Jul 2010, 05:19 PM
Hello Howard Rothman,

The old filtering API uses several parameters only for the Between function in the predicates. In order to implement your scenario, you must add two FilterExpressions in the FilterExpressions collection:

FilterExpression filter = new FilterExpression();
filter.FieldName = this.radGridView1.Columns[0].UniqueName;
filter.Predicates.Add(FilterExpression.BinaryOperation.OR, GridKnownFunction.EqualTo, "CT");
grdModality.MasterGridViewTemplate.FilterExpressions.Add(filter);
filter = new FilterExpression();
filter.FieldName = this.radGridView1.Columns[0].UniqueName;
filter.Predicates.Add(FilterExpression.BinaryOperation.OR, GridKnownFunction.EqualTo, "abcd");
grdModality.MasterGridViewTemplate.FilterExpressions.Add(filter);

If you are using the new version of RadGridView control (Q2 2010), the new API is:
this.radGridView1.FilterDescriptors.LogicalOperator = FilterLogicalOperator.Or;
this.radGridView1.FilterDescriptors.Add(this.radGridView1.Columns[0].Name, FilterOperator.IsEqualTo, "CT");
this.radGridView1.FilterDescriptors.Add(this.radGridView1.Columns[0].Name, FilterOperator.IsEqualTo, "abcd");

I hope this helps.

Best wishes,
Julian Benkov
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
GridView
Asked by
Eric
Top achievements
Rank 1
Answers by
Jordan
Telerik team
Edmund Jung
Top achievements
Rank 1
Jack
Telerik team
tyler thompson
Top achievements
Rank 1
Charlie
Top achievements
Rank 1
Howard Rothman
Top achievements
Rank 1
Julian Benkov
Telerik team
Share this question
or