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

disable filtering on a column

2 Answers 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dario Zanelli
Top achievements
Rank 1
Dario Zanelli asked on 06 Jul 2010, 04:45 PM
Hi all,
I have a asp.net page with a Telerik Radgrid control with dynamically generated columns.
I cannot disable the filtering function on a column, even using the AllowFiltering option set to false.
I send you the C# code that generates the columns. There are many columns that are not visible, but editable in the edit form. I don't know whether this can affect the filtering function.
The shown column "Key Control" displays the filter even if I have disabled it. The filter doesn't even work.

this.RadGrid_Processes.MasterTableView.EditMode = GridEditMode.EditForms;

this.RadGrid_Processes.Width = Unit.Pixel(855);

if (controlState.Equals(STATE_NAVIGATING) || controlState.Equals(STATE_LINKING))
{
    this.pnlInstructions.Visible = true;
}
else
{
    this.pnlInstructions.Visible = false;
    this.lblInstructions.Text = "";
}

this.RadGrid_Processes.AllowFilteringByColumn = true;
this.RadGrid_Processes.MasterTableView.AllowFilteringByColumn = true;

boundColumn = new GridBoundColumn();
this.RadGrid_Processes.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "Id";
boundColumn.HeaderText = "Id";
boundColumn.UniqueName = "Id";
boundColumn.Visible = false;
boundColumn.ReadOnly = true;

boundColumn = new GridBoundColumn();
this.RadGrid_Processes.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "Code";
boundColumn.HeaderText = "Code";
boundColumn.SortExpression = "Code";
boundColumn.UniqueName = "Code";
boundColumn.HeaderStyle.Width = Unit.Pixel(90);

boundColumn.CurrentFilterValue = String.Empty;
boundColumn.ShowFilterIcon = false;
boundColumn.CurrentFilterFunction = GridKnownFunction.Contains;
boundColumn.AutoPostBackOnFilter = false;
boundColumn.FilterDelay = 1000;
boundColumn.FilterControlWidth = 80;
boundColumn.AllowFiltering = true;


boundColumn = new GridBoundColumn();
this.RadGrid_Processes.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "Description";
boundColumn.HeaderText = "Description";
boundColumn.SortExpression = "Description";
boundColumn.UniqueName = "Description";
boundColumn.HeaderStyle.Width = Unit.Pixel(650);

boundColumn.CurrentFilterValue = String.Empty;
boundColumn.ShowFilterIcon = false;
boundColumn.CurrentFilterFunction = GridKnownFunction.Contains;
boundColumn.AutoPostBackOnFilter = false;
boundColumn.FilterDelay = 1000;
boundColumn.FilterControlWidth = 600;
boundColumn.AllowFiltering = true;

boundColumn = new GridBoundColumn();
this.RadGrid_Processes.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "TestMode";
boundColumn.HeaderText = "Test Mode";
boundColumn.SortExpression = "TestMode";
boundColumn.UniqueName = "TestMode";
boundColumn.Visible = false;
//boundColumn.AllowFiltering = false;

dropDownColumn = new GridDropDownColumn();
this.RadGrid_Processes.MasterTableView.Columns.Add(dropDownColumn);
dropDownColumn.DataField = "FK_ControlType";
dropDownColumn.DataSourceID = this.LinqDataSource_ControlType.ID;
dropDownColumn.ListValueField = "Id";
dropDownColumn.ListTextField = "Description";
dropDownColumn.HeaderText = "Control Type";
dropDownColumn.UniqueName = "Control Type";
dropDownColumn.HeaderStyle.Width = Unit.Pixel(90);
dropDownColumn.EnableEmptyListItem = true;
dropDownColumn.EmptyListItemText = "Select...";
dropDownColumn.Visible = false;
dropDownColumn.EditFormColumnIndex = 1;
//boundColumn.AllowFiltering = false;

dropDownColumn = new GridDropDownColumn();
this.RadGrid_Processes.MasterTableView.Columns.Add(dropDownColumn);
dropDownColumn.DataField = "FK_KeyControl";
dropDownColumn.DataSourceID = this.LinqDataSource_YesNo.ID;
dropDownColumn.ListValueField = "Id";
dropDownColumn.ListTextField = "Description";
dropDownColumn.HeaderText = "Key Control";
dropDownColumn.UniqueName = "KeyControl";
dropDownColumn.HeaderStyle.Width = Unit.Pixel(70);
dropDownColumn.EnableEmptyListItem = true;
dropDownColumn.EmptyListItemText = "Select...";
//dropDownColumn.Visible = true;
dropDownColumn.EditFormColumnIndex = 1;
//boundColumn.ShowFilterIcon = false;
boundColumn.AllowFiltering = false;                   

dropDownColumn = new GridDropDownColumn();
this.RadGrid_Processes.MasterTableView.Columns.Add(dropDownColumn);
dropDownColumn.DataField = "FK_Formalized";
dropDownColumn.DataSourceID = this.LinqDataSource_YesNo.ID;
dropDownColumn.ListValueField = "Id";
dropDownColumn.ListTextField = "Description";
dropDownColumn.HeaderText = "Formalized";
dropDownColumn.UniqueName = "Formalized";
dropDownColumn.HeaderStyle.Width = Unit.Pixel(70);
dropDownColumn.EnableEmptyListItem = true;
dropDownColumn.EmptyListItemText = "Select...";
dropDownColumn.Visible = false;
dropDownColumn.EditFormColumnIndex = 1;
//boundColumn.AllowFiltering = false;

dropDownColumn = new GridDropDownColumn();
this.RadGrid_Processes.MasterTableView.Columns.Add(dropDownColumn);
dropDownColumn.DataField = "FK_ControlEvaluation";
dropDownColumn.DataSourceID = this.LinqDataSource_ControlEvaluation.ID;
dropDownColumn.ListValueField = "Id";
dropDownColumn.ListTextField = "Description";
dropDownColumn.HeaderText = "Control Evaluation";
dropDownColumn.UniqueName = "ControlEvaluation";
dropDownColumn.HeaderStyle.Width = Unit.Pixel(140);
dropDownColumn.EnableEmptyListItem = true;
dropDownColumn.EmptyListItemText = "Select...";
dropDownColumn.Visible = false;
dropDownColumn.EditFormColumnIndex = 1;
//boundColumn.AllowFiltering = false;

dropDownColumn = new GridDropDownColumn();
this.RadGrid_Processes.MasterTableView.Columns.Add(dropDownColumn);
dropDownColumn.DataField = "FK_ControlFrequency";
dropDownColumn.DataSourceID = this.LinqDataSource_ControlFrequency.ID;
dropDownColumn.ListValueField = "Id";
dropDownColumn.ListTextField = "Description";
dropDownColumn.HeaderText = "Control Frequency";
dropDownColumn.UniqueName = "ControlFrequency";
dropDownColumn.HeaderStyle.Width = Unit.Pixel(135);
dropDownColumn.EnableEmptyListItem = true;
dropDownColumn.EmptyListItemText = "Select...";
dropDownColumn.Visible = false;
dropDownColumn.EditFormColumnIndex = 1;
//boundColumn.AllowFiltering = false;

this.RadGrid_Processes.MasterTableView.EditFormSettings.ColumnNumber = 2;
this.RadGrid_Processes.MasterTableView.EditFormSettings.EditColumn.ButtonType = GridButtonColumnType.PushButton;

The telerik version I am currently using in Q3 2009 SP1. If it is a bug, is it solved in the newest version?

Thanks in advance.

Best regards,

Dario Zanelli

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Jul 2010, 07:56 AM
Hello Dario,

I have tried the same code and it is working on my end (RadControl Version: 2009, 3, 1103, 35). The only mistake that i can see is that you have set " boundColumn.AllowFiltering " as "false" for DropDownColumn( I guess you meant for DropDownColumn). If you do not want filtering for DropDownColumn, then set dropDownColum.AllowFiltering as false.

C#:
      
        GridDropDownColumn dropDownColumn = 
new GridDropDownColumn(); 
        this.RadGrid1.MasterTableView.Columns.Add(dropDownColumn); 
        dropDownColumn.DataField = "FirstName"
        dropDownColumn.DataSourceID = this.SqlDataSource1.ID; 
        dropDownColumn.ListValueField = "FirstName"
        dropDownColumn.ListTextField = "FirstName"
        dropDownColumn.HeaderText = "FirstName"
        dropDownColumn.AllowFiltering = false;    

Also refer the following documentation which explains the programmatic creation of Grid and grid column.
Programmatic creation

I hope this helps you,
Princy.
0
Dario Zanelli
Top achievements
Rank 1
answered on 08 Jul 2010, 10:44 AM
Hi Princy!

Thanks for your prompt answer.
Actually I was setting the wrong column with allowfilterning = false.


Regards,

Dario Zanelli
Tags
Grid
Asked by
Dario Zanelli
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dario Zanelli
Top achievements
Rank 1
Share this question
or