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

[Solved] Custom filtering with combo boxes and Nested Views not working

2 Answers 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ulonda
Top achievements
Rank 1
Ulonda asked on 14 May 2013, 10:24 PM
We are having issues when applying refreshed combo box filters in addition to using NestedViews. Once we apply filters and rebind the NestedViews will no longer open/expand.

What I believe is happening is that Prerender is being invoked for both the filter as well as the NestedView expand. In PreRender I am calling a function that refreshes our filter combo boxes to relevant options post filter and rebinds the grid. At this point the filter is != string.Empty and when the row is clicked to expand the NestedView prerender fires again and my function is again called rebinding the grid and collapsing the NestedView. My question: is there any way to avoid this collision? Would it be possible to detect who invoked Prerender or move the combo refresh to Javascript?

We want to achieve the following goals:
  1. Refresh several combobox filter dropdowns after the user has filtered on a field, and rebind the grid
  2. Utilize nested views after filtering

Code is below:
protected void RadGrid1_PreRender(object sender, EventArgs e)
        {
            if (RadGrid1.MasterTableView.FilterExpression != string.Empty)
            {
                RefreshCombos();
            }
        }

protected void RefreshCombos()
{
SqlDataSourceVP.SelectCommand = SqlDataSourceVP.SelectCommand + " WHERE " +                               RadGrid1.MasterTableView.FilterExpression;
            SqlDataSourceTransStatus.SelectCommand = SqlDataSourceTransStatus.SelectCommand + " WHERE " + RadGrid1.MasterTableView.FilterExpression;
            SqlDataSourceTransType.SelectCommand = SqlDataSourceTransType.SelectCommand + " WHERE " + RadGrid1.MasterTableView.FilterExpression;
 RadGrid1.MasterTableView.Rebind();
}

2 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 17 May 2013, 12:53 PM
Hello,

Yes, you could use some bool variable to indicate whether the user has tried to expand/collapse a row. This could be done inside the ItemCommand event. By the default the bool value will have value of false and in the ItemCommand event you will set the value to true. In the PreRender event you will check for that variable and only if its value is true you will execute your logic.

Give this suggestion a try and you should not have problems.

All the best,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Ulonda
Top achievements
Rank 1
answered on 21 May 2013, 09:10 PM
Thanks that worked like a charm!
Tags
Grid
Asked by
Ulonda
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Ulonda
Top achievements
Rank 1
Share this question
or