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

Dynamic RadFilter

1 Answer 92 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Angad
Top achievements
Rank 1
Angad asked on 16 Sep 2015, 02:01 PM
Hello,
I am initializing the RadFIlter component from Server side.  After initializing, I am loading the collection list into the component. In the front end, whenever I am clicking on the item of the list, it works fine. There is a refresh interval timeout (5 seconds). After every 5 seconds, I am loading the values from the database on the front end grid.
So whenever I click on any Radfilter items after 5 seconds refresh interval, the error window appears which says "index was out of range. must be nonnegative and less than the size of the collection List". Within the 5 seconds interval, it works fine. It seems the values which I am loading on the server side are getting lost. 
I am performing the following steps;
1. On the page initialization, I am creating the Rad FIlter Component.
 this.ComplexFilter = new RadFilter()
                    {
                        ID = "ComplexFilter",
                           AllowFilterOnBlur = true,
                          ShowApplyButton = false,
                          Skin = "Vista",
                          EnableViewState = false
                                           
                    };
this.ComplexFilter.ItemCommand += this.ComplexFilter_OnItemCommand;
this.ComplexFilterPanel.ContentTemplateContainer.Controls.Add(this.ComplexFilter);
fieldEditor.FieldName = column.JsName; // column is the list of items. This I am doing for every column list item.
fieldEditor.DisplayName = column.Name;
 fieldEditor.DataType = column.Type;
this.ComplexFilter.FieldEditors.Add(fieldEditor);
 
var rootGroup = this.Settings.ComplexFilter_Expression;
 if (rootGroup != null)
                {
                    this.ComplexFilter.RootGroup.GroupOperation = rootGroup.GroupOperation;
                     foreach (var expression in rootGroup.Expressions)
                    {
                        this.ComplexFilter.RootGroup.AddExpression(expression);
                    }
                } 
                this.ComplexFilter.PreRender += this.ComplexFilter_OnPreRender;
  
void ComplexFilter_OnUpdate(object sender, EventArgs args)
        {
            string previousComplexFilterSql;
             string newComplexFilterSql; 
            if (this.Settings.ComplexFilter_Sql != null)
            {
                previousComplexFilterSql = this.Settings.ComplexFilter_Sql;
            }
            else
            {
                if (this.Settings.ComplexFilter_Expression != null)
                {
                    previousComplexFilterSql = this.Settings.ComplexFilter_Expression.ToWhere(this.TablesTable).ToString();
                }
                else
                {
                    previousComplexFilterSql = String.Empty;
                }
            } 
            if (this.Settings.ComplexFilter_Visible)
            {
                this.Settings.ComplexFilter_Expression = this.ComplexFilter.RootGroup;
 
                newComplexFilterSql = this.Settings.ComplexFilter_Sql = this.Settings.ComplexFilter_Expression.ToWhere(this.TablesTable).ToString();
            }
            else
            {
                newComplexFilterSql = String.Empty;
            } 
            this.ComplexFilter_ReloadData(previousComplexFilterSql, newComplexFilterSql); 
            ComplexFilter.RecreateControl(); 
        }
 
  2. After every 5 seconds Refresh timeout, I am checking for the complex filter saved settings. But due to the null value of ComplexFilter_Expression, settings could not be fetched from the database.
   if (this.ComplexFilter_Visible && this.ComplexFilter_Expression != null)
            {
                where &= this.ComplexFilter_Expression.GetDBWhere(table, joins, out saveSettings); 
            }
            else
            {
                saveSettings = false;
            }


I request to the Telerik expertise, to tell me what I am doing wrong. Why the Telerik object is getting lost due the front end refresh time interval.

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 22 Sep 2015, 10:33 AM
Hi,

The information provided is not sufficient for us to determine the root cause of the issue. Moreover since the control is initially created it seems that all should be working fine.

In order for us to provide a precise answer regarding this matter I would recommend isolating the issue in a separate sample which we can debug. Information on how to achieve this is provided here.

Regards,
Angel Petrov
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Filter
Asked by
Angad
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or