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

Custom Filter Column and no viewstate problem

1 Answer 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert Field
Top achievements
Rank 1
Robert Field asked on 21 Dec 2010, 11:37 AM
Hello,

I am using a Grid with a custom filter column as described in the demo http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filteringtemplatecolumns/defaultcs.aspx 

The problem I have is that when I turn off the viewstate for the grid the event below does not fire in the event chain.
private void rcBox_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
     {
         ((GridFilteringItem)(((RadComboBox)sender).Parent.Parent)).FireCommandEvent("Filter", new Pair());
     }


        private void rcBox_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            ((GridFilteringItem)(((RadComboBox)sender).Parent.Parent)).FireCommandEvent("Filter", new Pair());
        }
   private void rcBox_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            ((GridFilteringItem)(((RadComboBox)sender).Parent.Parent)).FireCommandEvent("Filter", new Pair());
        }
If I turn on view state then it works fine. I have tried setting the selectedvalue in the "protected override void SetupFilterControls(TableCell cell)" method as follows, but all that does is maintain the selectedvalue during postback and does not cause the  rcBox_SelectedIndexChangedevent to fire. You can see from the code below I tried to fire the Filter command but it is too early and causes other problems.

var formvalue = HttpContext.Current.Request.Form[rcBox.UniqueID];
           if (!string.IsNullOrEmpty(formvalue))
           {
               rcBox.SelectedValue = formvalue;
               //((GridFilteringItem)(rcBox.Parent.Parent)).FireCommandEvent("Filter", new Pair());
           }


Is this a bug in the grid, my only solution is to use viewstate but this is a large gird.

I have also notcied that if the viewstate is switched off you can not change page with the page number buttons and can only use the left and right page buttons.

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 23 Dec 2010, 03:56 PM
Hello Robert,

The described behavior is rather expected. When RadGrid ViewState is disabled, RadGrid is rebound on each postback and its controls are recreated. This happens at load stage of the page lifecycle. Thus the combobox looses its selection and that is why its SelectedIndexChanged event if not fired.
Therefore I suggest that you either enable the ViewState or use FilterTemplate and fire the filter command for the grid with client-side code.

Regards,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Robert Field
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or