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

Adding fields to Rad Filter

5 Answers 95 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
KIRAN RAJ
Top achievements
Rank 1
KIRAN RAJ asked on 22 Sep 2011, 12:21 PM
Hi friends,
I have been trying to place some extra  fields like field1field2 along with the Rad grid columns into rad filter. When i am trying below code i am not able to see my added fields 'field1field2" in rad filter.  any suggestions..? i DONT WANT TO USE DATASOURCE ID..
<body>
    <form id="form1" runat="server">
    <div>
     
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
        </telerik:RadScriptManager>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <br />
        <telerik:RadFilter ID="RadFilter1" runat="server" FilterContainerID="RadGrid1"
            onapplyexpressions="RadFilter1_ApplyExpressions">
            <FieldEditors>
            <telerik:RadFilterTextFieldEditor FieldName="field1"  DataType="System.String" />
              <telerik:RadFilterTextFieldEditor FieldName="field2"  DataType="System.String" />
            </FieldEditors>
        </telerik:RadFilter>
        <br />
        <br />
     
    </div>
    <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" GridLines="None"
        AllowAutomaticInserts="True"
        DataSourceID="SqlDataSource1" 
        ShowGroupPanel="True">
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
 
<MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1" >
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
</RowIndicatorColumn>
 
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
</ExpandCollapseColumn>
 
    <Columns>
        <telerik:GridBoundColumn DataField="MachineName"
            FilterControlAltText="Filter MachineName column" HeaderText="MachineName"
            SortExpression="MachineName" UniqueName="MachineName">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="OperatingSystem"
            FilterControlAltText="Filter OperatingSystem column"
            HeaderText="OperatingSystem" SortExpression="OperatingSystem"
            UniqueName="OperatingSystem">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Location"
            FilterControlAltText="Filter Location column" HeaderText="Location"
            SortExpression="Location" UniqueName="Location">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="IPAddress"
            FilterControlAltText="Filter IPAddress column" HeaderText="IPAddress"
            SortExpression="IPAddress" UniqueName="IPAddress" Visible=false>
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Site_Name"
            FilterControlAltText="Filter Site_Name column" HeaderText="Site_Name"
            SortExpression="Site_Name" UniqueName="Site_Name" >
        </telerik:GridBoundColumn>
      
         <telerik:GridBoundColumn DataField="Status_ID"
            FilterControlAltText="Filter Status_ID column" HeaderText="Status_ID"
            SortExpression="Status_ID" UniqueName="Status_ID" Visible=false >
        </telerik:GridBoundColumn>
    </Columns>
 
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
 
        <ClientSettings AllowDragToGroup="True">
            <Scrolling AllowScroll="True" UseStaticHeaders="True" />
        </ClientSettings>
 
<FilterMenu EnableImageSprites="False" DataValueField="Location"></FilterMenu>
    </telerik:RadGrid>
    <telerik:RadAjaxManager runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:sitemgrConnectionString %>"
        SelectCommand="TELRIK" SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>
    </form>
</body>
</html>
The code i am using to create dataset..
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class _Default : System.Web.UI.Page
{
    string conStr = ConfigurationManager.ConnectionStrings["conn44"].ConnectionString;
 
    
    
    protected void Page_Load(object sender, EventArgs e)
    {
 
         
            RadGrid1.GroupingSettings.CaseSensitive = false;
            RadGrid1.ShowGroupPanel = true;
            RadGrid1.ClientSettings.AllowDragToGroup = true;
 
            RadFilterTextFieldEditor editor1 = new RadFilterTextFieldEditor();
            RadFilter1.FieldEditors.Add(editor1);
            editor1.FieldName = "field1";
            editor1.DataType = typeof(string);
            editor1.DisplayName = "field1";
 
           RadFilterTextFieldEditor editor2 = new RadFilterTextFieldEditor();
            RadFilter1.FieldEditors.Add(editor2);
            editor2.FieldName = "field2";
            editor2.DataType = typeof(string);
            editor2.DisplayName = "field2";
         
  
    }
 
    protected void RadFilter1_ApplyExpressions(object sender, RadFilterApplyExpressionsEventArgs e)
    {
        RadFilterSqlQueryProvider provider = new RadFilterSqlQueryProvider();
        provider.ProcessGroup(e.ExpressionRoot);
        Label1.Text = provider.Result;
    }
}

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Sep 2011, 01:25 PM
Hello Kiran Raj,

Try the same code in the Page_init() event.
C#:
protected void Page_Init(object sender, EventArgs e)
   {
       RadFilterTextFieldEditor editor1 = new RadFilterTextFieldEditor();
       RadFilter1.FieldEditors.Add(editor1);
       editor1.FieldName = "field1";
       editor1.DataType = typeof(string);
       editor1.DisplayName = "field1";
   }

Also take a look into this following documentation:
Adding Field Editors Dynamically

Thanks,
Princy.
0
KIRAN RAJ
Top achievements
Rank 1
answered on 22 Sep 2011, 02:16 PM
hi Princy,
Thank you...I have tried ur code but it's not working....
0
Mira
Telerik team
answered on 22 Sep 2011, 03:07 PM
Hello Kiran,

Do you want to add RadFilter expressions programmatically?
You can examine the Working with Expressions help topic to see how this can be done.

I hope it helps.

Kind regards,
Mira
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
KIRAN RAJ
Top achievements
Rank 1
answered on 23 Sep 2011, 06:42 AM
HI ,
thanks princy and meera, 
I have  a select query selecting 4 columns and putting that into rad grid , these fields adding to rad filter as well..But what i need is apart from these 4 fields i want to show another 2 more fields in rad filter and perform filtering on rad grid .
(I have tried taking 6 fields in rad filter and hiding 2 fields , i want another approch ) 
0
Mira
Telerik team
answered on 28 Sep 2011, 09:49 AM
Hello Kiran,

I tried to replicate the issue which you described, but to no avail - field editors are generated for the fields which columns are not visible in the grid as well.
Attached to this message, you will find the code which I used for testing.

If the issue persists, please open a formal support ticket and attach a sample project demonstrating it. We will examine it locally and get back to you with our findings.

Regards,
Mira
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
Tags
Ajax
Asked by
KIRAN RAJ
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
KIRAN RAJ
Top achievements
Rank 1
Mira
Telerik team
Share this question
or