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

Filter in more than one columns in dynamically created grid

11 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ferdinand
Top achievements
Rank 1
Ferdinand asked on 07 Dec 2009, 04:29 PM
Hello
I have a grid that is created dynamically by the data that is passed. I create the grid's columns in code behind and bind the grid on every postback.
That works fine for the beginning. Even filtering works fine. But when I filer more than one columns the first column's filter gets lost.

Is there a way to persist the grid's filter settings or to load my data in a way that the grid's settings do not get lost?

Thanks in advance

Ferdinand

11 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 07 Dec 2009, 05:52 PM
Hello Ferdinand,

Please review this article on how to create RadGrid programmatically. At the bottom you can find how to create grid template columns dynamically.
Please check it out and let me know what is the difference in your scenario.

All the best, Pavlina
the Telerik team

 


Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ferdinand
Top achievements
Rank 1
answered on 08 Dec 2009, 07:32 AM
Hi Pavlina,
as a matter of fact I did not create the whole grid in code-behind although I have dynamically created template columns in the gird. I will give it a try and post my results.

Best regards
Ferdinand
0
Ferdinand
Top achievements
Rank 1
answered on 08 Dec 2009, 09:43 AM
Hi,
I tried out implementing the whole grid in code behind and now filtering works perfectly fine. But only if I do not use the ajax manager. If I ajaxify the control (doesn't matter if I put an UpdatePanel around the PlaceHolder or if I use the AjaxManager from code behind) no postback functionality works.

Is there any known issue with that problem?

Best regards
Ferdinand
0
Ferdinand
Top achievements
Rank 1
answered on 08 Dec 2009, 11:15 AM
I figured it out. Everything works fine now.

Thanks again
Ferdinand
0
Pavlina
Telerik team
answered on 09 Dec 2009, 01:36 PM
Hello Ferdinand,

I am glad to hear you have found a suitable solution for your case.
Do not hesitate to write us again if any questions arise.

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Manuel Ortiz
Top achievements
Rank 1
answered on 10 May 2010, 10:49 PM
Hi,

I also have it everything done on Code Behind but multiple column filtering is still not working.  How did you solved it or figured it out?

Thanks,
Manuel
0
Pavlina
Telerik team
answered on 13 May 2010, 09:16 AM
Hi Manuel,

Could you please send us your page declaration (aspx file) this would be of help to get to the source of the issue and advise you further?

Regards,
Pavlina
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Manuel Ortiz
Top achievements
Rank 1
answered on 13 May 2010, 09:28 PM
Hey Pavlina, here is the code of the page declaration file.

Regards,
Manuel

<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" 
    CodeFile="GridView.aspx.vb" Inherits="GridView" %> 
 
<asp:Content ID="Content1" ContentPlaceHolderID="HeadPlaceholder" runat="server"
    <title></title
    <link href="styles/grid.css" rel="stylesheet" type="text/css" /> 
     
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
        <script type="text/javascript" src="js/ValidationScripts.js"></script> 
        <script type="text/javascript" src="js/HandleKeyPress.js"></script> 
        <script type="text/javascript" src="js/PopupWindowScripts.js"></script> 
        <script type="text/javascript" src="js/LoadingPanelScripts.js"></script> 
        <script type="text/javascript" src="js/FilterScripts.js"></script> 
         
        <script type="text/javascript"
            function RequestStart(sender, args) { 
                    RequestStartFSLP("<%= pageLoadingPanel.ClientID %>"); 
            }                
        </script> 
    </telerik:RadCodeBlock> 
     
    <style type="text/css"
 
    </style> 
</asp:Content> 
 
<asp:Content ID="Content2" ContentPlaceHolderID="MainColumnPlaceholder" runat="Server"
    <div id="single" class="box-style-gridview"
        <h2 class="title"><strong> 
            MANAGE <asp:Label ID="lblEntityName" runat="server" CssClass="darkBlueFont" Text=""></asp:Label> 
        </strong></h2
         <%--<h4>Use this page to view and/or manage your <asp:Label ID="lblEntityNameText" runat="server" Text=""></asp:Label> 
            </h4> --%>    
             
        <div class="grid">        
            <telerik:RadDatePicker ID="RadDatePicker1" Style="display: none;" MinDate="2009-01-01" 
                MaxDate="2100-12-31" runat="server" DateInput-DateFormat="MM/dd/yyyy" ClientEvents-OnDateSelected="dateSelected" 
                Skin="Outlook"
            </telerik:RadDatePicker>   
             
            <asp:PlaceHolder runat="server" ID="GridPlaceholder"></asp:PlaceHolder>               
        </div> 
 
        <div style="clear: both"></div> 
    </div>     
     
     <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1"
        <ClientEvents OnRequestStart="RequestStart" />          
     </telerik:RadAjaxManager> 
     
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px" 
            Width="75px" InitialDelayTime="500" BackgroundPosition="Center" Skin="Outlook"
    </telerik:RadAjaxLoadingPanel> 
     
    <telerik:RadAjaxLoadingPanel ID="pageLoadingPanel" runat="server"  
        CssClass="fsLoadingPanel" Transparency="2" IsSticky="True" InitialDelayTime="500" 
        BackgroundPosition="None" BackImageUrl="~/images/orangeoutlookloader.gif" 
        EnableEmbeddedSkins="False" Skin="Outlook">    
    </telerik:RadAjaxLoadingPanel> 
     
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Modal="True" Skin="Outlook"   
    AutoSize="True" Width="700" Height="600" ShowContentDuringLoad="False" Style="z-index:7001"
    </telerik:RadWindowManager> 
 
    <telerik:RadInputManager ID="RadInputManager1" runat="server" Skin="Outlook"
        <telerik:DateInputSetting BehaviorID="ReqDateTimeBehavior" EmptyMessage="<%$ AppSettings:sInputRequiredText %>" 
            ErrorMessage="Invalid entry..." Validation-IsRequired="True" InitializeOnClient="false" Validation-ValidateOnEvent="Submit"  
            DateFormat="MM/dd/yyyy" ClientEvents-OnKeyPress="handlekeypressed"
        </telerik:DateInputSetting> 
        <telerik:DateInputSetting BehaviorID="DateTimeBehavior" InitializeOnClient="false" 
            DateFormat="MM/dd/yyyy" ErrorMessage="Invalid entry..." EmptyMessage="<%$ AppSettings:sInputOptionalText %>" 
            ClientEvents-OnKeyPress="handlekeypressed"
        </telerik:DateInputSetting> 
        <telerik:RegExpTextBoxSetting BehaviorID="ReqEMailBehavior" InitializeOnClient="false" 
            ErrorMessage="Invalid entry..." EmptyMessage="<%$ AppSettings:sInputRequiredText %>" Validation-IsRequired="true" 
            ValidationExpression="^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$" ClientEvents-OnKeyPress="handlekeypressed"
        </telerik:RegExpTextBoxSetting> 
        <telerik:RegExpTextBoxSetting BehaviorID="EMailBehavior" InitializeOnClient="false" 
            ErrorMessage="Invalid entry..." EmptyMessage="<%$ AppSettings:sInputOptionalText %>" ValidationExpression="^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$" 
            ClientEvents-OnKeyPress="handlekeypressed"
        </telerik:RegExpTextBoxSetting> 
        <telerik:RegExpTextBoxSetting BehaviorID="ReqSSBehavior" InitializeOnClient="false" 
            ErrorMessage="Invalid entry..." EmptyMessage="<%$ AppSettings:sInputRequiredText %>" Validation-IsRequired="true" 
            ValidationExpression="(^|\s)(\d{2}[-]\d{7}|\d{2}[ ]\d{7}|\d{3}[-]\d{2}[-]\d{4}|\d{3}[ ]\d{2}[ ]\d{4})($|\s)" 
            ClientEvents-OnKeyPress="handlekeypressed"
        </telerik:RegExpTextBoxSetting> 
        <telerik:RegExpTextBoxSetting BehaviorID="SSBehavior" InitializeOnClient="false" 
            ErrorMessage="Invalid entry..." EmptyMessage="<%$ AppSettings:sInputOptionalText %>" ValidationExpression="(^|\s)(\d{2}[-]\d{7}|\d{2}[ ]\d{7}|\d{3}[-]\d{2}[-]\d{4}|\d{3}[ ]\d{2}[ ]\d{4})($|\s)" 
            ClientEvents-OnKeyPress="handlekeypressed"
        </telerik:RegExpTextBoxSetting> 
        <telerik:RegExpTextBoxSetting BehaviorID="ReqPhoneBehavior" InitializeOnClient="false" 
            ErrorMessage="Invalid entry..." EmptyMessage="<%$ AppSettings:sInputRequiredText %>" Validation-IsRequired="true" 
            ValidationExpression="(^|\s)\(?\d{3}\)?(\.|\,|\-|\ )?\d{3}(\.|\,|\-|\ )?(\d{4}\ ?)$" 
            ClientEvents-OnKeyPress="handlekeypressed"
        </telerik:RegExpTextBoxSetting> 
        <telerik:RegExpTextBoxSetting BehaviorID="PhoneBehavior" InitializeOnClient="false"  
            ErrorMessage="Invalid entry..." EmptyMessage="<%$ AppSettings:sInputOptionalText %>" ValidationExpression="(^|\s)\(?\d{3}\)?(\.|\,|\-|\ )?\d{3}(\.|\,|\-|\ )?(\d{4}\ ?)$" 
            ClientEvents-OnKeyPress="handlekeypressed"
        </telerik:RegExpTextBoxSetting> 
        <telerik:RegExpTextBoxSetting BehaviorID="ReqPostalCodeBehavior" InitializeOnClient="false" 
            ErrorMessage="Invalid entry..." EmptyMessage="<%$ AppSettings:sInputRequiredText %>" Validation-IsRequired="true" 
            ValidationExpression="(^|\s)((\d{5}-\d{4})|(\d{5})|([AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvXxYy]\d[A-Za-z]\s?\d[A-Za-z]\d))$" 
            ClientEvents-OnKeyPress="handlekeypressed"
        </telerik:RegExpTextBoxSetting> 
        <telerik:RegExpTextBoxSetting BehaviorID="PostalCodeBehavior" InitializeOnClient="false" 
            ErrorMessage="Invalid entry..." EmptyMessage="<%$ AppSettings:sInputOptionalText %>" ValidationExpression="(^|\s)((\d{5}-\d{4})|(\d{5})|([AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvXxYy]\d[A-Za-z]\s?\d[A-Za-z]\d))$" 
            ClientEvents-OnKeyPress="handlekeypressed"
        </telerik:RegExpTextBoxSetting> 
        <telerik:TextBoxSetting BehaviorID="ReqTextBoxBehavior" InitializeOnClient="false" 
            EmptyMessage="Required field..." Validation-IsRequired="True" ErrorMessage="Required field..."
        </telerik:TextBoxSetting> 
        <telerik:TextBoxSetting BehaviorID="TextBoxBehavior" InitializeOnClient="false" EmptyMessage="<%$ AppSettings:sInputOptionalText %>" 
            ClientEvents-OnKeyPress="handlekeypressed" /> 
        <telerik:NumericTextBoxSetting BehaviorID="ReqCurrencyBehavior" InitializeOnClient="false" NegativePattern="$-n"  
            Type="Currency" DecimalDigits="2" Validation-IsRequired="true" ErrorMessage="Required field..." 
            EmptyMessage="<%$ AppSettings:sInputRequiredText %>" ClientEvents-OnKeyPress="handlekeypressed" /> 
        <telerik:NumericTextBoxSetting BehaviorID="CurrencyBehavior" InitializeOnClient="false" 
            Type="Currency" DecimalDigits="2" ErrorMessage="Required field..." EmptyMessage="<%$ AppSettings:sInputOptionalText %>" NegativePattern="$-n" /> 
        <telerik:NumericTextBoxSetting BehaviorID="ReqRateBehavior" InitializeOnClient="false"  
            Type="Percent" DecimalDigits="4" Validation-IsRequired="true" ErrorMessage="Required field..." 
            EmptyMessage="<%$ AppSettings:sInputRequiredText %>" ClientEvents-OnKeyPress="handlekeypressed" /> 
        <telerik:NumericTextBoxSetting BehaviorID="RateBehavior" InitializeOnClient="false"  
            Type="Percent" DecimalDigits="4" ErrorMessage="Invalid entry..." EmptyMessage="<%$ AppSettings:sInputOptionalText %>" 
            ClientEvents-OnKeyPress="handlekeypressed" /> 
    </telerik:RadInputManager> 
 
 
</asp:Content> 
 

0
Pavlina
Telerik team
answered on 14 May 2010, 03:57 PM
Hi Manuel,

Please, excuse me for the mistake I need your code-behind declaration. In the previous post you said that you done everithing in code behind. Thus we can check if there are any problems there.

Thank you for your cooperation in advance.

All the best,
Pavlina
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Manuel Ortiz
Top achievements
Rank 1
answered on 14 May 2010, 07:10 PM
Hello, I was consulting the legal department about sending you the code behind but due to company restrictions I cannot do that.

However, I can tell you that I followed the exact same instructions of the grid on page-init demo.  The only difference is that I enabled filtering and AutoPostBackOnFilter to True in some of the columns.  By further testing I have found that when I don't include the CurrentFilterFunction in the column's declaration, the value of the column's filter is never persisted after postback.  However, If I include a CurrentFilterFunction in the column declaration, the value is always persisted; but If I change the filter function in the filter's dropdown it returns to the CurrentFilterFunction declared in the column declaration. 

In other words, If I have CurrentFiterFunction set to "EqualTo" and I change it to "GreaterThan" using the filter's control dropdown, it filters by greater than but in the subsequent postback it goes back to "EqualTo" nevertheless I want it to stay on "GreaterThan" when I am filtering other columns.  I have checked and re-checked everything and it looks perfect.  I have no idea what else I can do.

Thanks,
Manuel
0
Pavlina
Telerik team
answered on 15 May 2010, 03:42 PM
Hello Manuel,

In order to overcome the described issues with the CurrentFilterValue and CurrentFilterFunction, I would suggest you to set the for the desired columns on initial load, i.e. in if(!IsPostBack) statement instead of on each Page_Init.

Please give it a try and let me know how it goes.

Best wishes,
Pavlina
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Ferdinand
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Ferdinand
Top achievements
Rank 1
Manuel Ortiz
Top achievements
Rank 1
Share this question
or