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

RadGrid Filter is not working

1 Answer 109 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
kd
Top achievements
Rank 1
kd asked on 13 Mar 2012, 11:57 AM
Hi all,
i have bound rad grid with entity data source object and allow all feature of rad grid true like filter , sorting, inserting, updating , paging and deleting . all operations are working well but filter is not working my code is follows
 i have also added ajax manger
<telerik:RadAjaxManager ID="RadAjaxManager2" runat="server">       
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rg_AllMembers">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rg_AllMembers" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

<telerik:RadGrid ID="rg_AllMembers" runat="server" DataSourceID="EntityDataSource_AllMembers"
                                   GridLines="None" AllowPaging="True" AllowAutomaticUpdates="True" AllowAutomaticInserts="True"
                                   AllowAutomaticDeletes="true" AllowSorting="true" Width="100%" AllowFilteringByColumn="true"
                                   AllowMultiRowEdit="false">
                                   <PagerStyle Mode="NextPrevAndNumeric" />
                                   <MasterTableView DataSourceID="EntityDataSource_AllMembers" AutoGenerateColumns="False"
                                       DataKeyNames="ID" CommandItemDisplay="Top" AllowMultiColumnSorting="false">
                                       <Columns>
                                           <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                                           </telerik:GridEditCommandColumn>
                                           <telerik:GridBoundColumn DataField="ID" HeaderText="ID" UniqueName="ID" Visible="false"
                                               ReadOnly="true" AllowFiltering="false">
                                           </telerik:GridBoundColumn>
                                           <telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" UniqueName="FirstName"
                                               AllowFiltering="true">
                                           </telerik:GridBoundColumn>
                                           <telerik:GridBoundColumn DataField="LastName" HeaderText="LastName" UniqueName="LastName"
                                               AllowFiltering="true">
                                           </telerik:GridBoundColumn>
                                           <telerik:GridBoundColumn DataField="PrimaryEmailAddress" HeaderText="Email" UniqueName="PrimaryEmailAddress"
                                               AllowFiltering="false">
                                           </telerik:GridBoundColumn>
                                           <telerik:GridBoundColumn DataField="RoleName" HeaderText="RoleName" UniqueName="RoleName"
                                               AllowFiltering="false">
                                           </telerik:GridBoundColumn>
                                           <telerik:GridBoundColumn DataField="Phone" HeaderText="Phone" UniqueName="Phone"
                                               AllowFiltering="false">
                                           </telerik:GridBoundColumn>
                                           <telerik:GridBoundColumn DataField="IsEmailVerified" HeaderText="Verified Email"
                                               UniqueName="IsEmailVerified" AllowFiltering="false">
                                           </telerik:GridBoundColumn>
                                           <telerik:GridBoundColumn DataField="IsActive" HeaderText="Active Member" UniqueName="IsActive"
                                               AllowFiltering="false" DataType="System.Boolean" DataFormatString="{false:N0}">
                                           </telerik:GridBoundColumn>
                                           <telerik:GridBoundColumn DataField="RegisteredIPAddress" HeaderText="IP Address"
                                               UniqueName="RegisteredIPAddress" AllowFiltering="false">
                                           </telerik:GridBoundColumn>
                                           <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton" />
                                       </Columns>
                                       <DetailTables>
                                           <telerik:GridTableView DataSourceID="EntityDataSource_Address" CommandItemDisplay="Top"
                                               DataKeyNames="ID,UserID" Width="100%" AllowAutomaticUpdates="true" AutoGenerateColumns="false"
                                               AllowAutomaticDeletes="true" AllowAutomaticInserts="true" InsertItemPageIndexAction="ShowItemOnCurrentPage"
                                               EditMode="EditForms" AllowMultiColumnSorting="false">
                                               <ParentTableRelation>
                                                   <telerik:GridRelationFields DetailKeyField="UserID" MasterKeyField="ID" />
                                               </ParentTableRelation>
                                               <Columns>
                                                   <telerik:GridEditCommandColumn ButtonType="ImageButton" />
                                                   <telerik:GridBoundColumn DataField="UserID" HeaderText="ID" ReadOnly="true" ForceExtractValue="Always"
                                                       AllowFiltering="false" Visible="false" />
                                                   <telerik:GridBoundColumn DataField="StreetNum" UniqueName="StreetNum" HeaderText="StreetNum"
                                                       AllowFiltering="false">
                                                   </telerik:GridBoundColumn>
                                                   <telerik:GridBoundColumn DataField="StreetName" UniqueName="StreetName" HeaderText="StreetName"
                                                       AllowFiltering="false">
                                                   </telerik:GridBoundColumn>
                                                   <telerik:GridBoundColumn DataField="SuiteNo" UniqueName="SuiteNo" HeaderText="SuiteNo"
                                                       AllowFiltering="false">
                                                   </telerik:GridBoundColumn>
                                                   <telerik:GridBoundColumn DataField="CityName" UniqueName="CityName" HeaderText="CityName"
                                                       AllowFiltering="false">
                                                   </telerik:GridBoundColumn>
                                                   <telerik:GridBoundColumn DataField="State_Province" UniqueName="State_Province" HeaderText="State/Province"
                                                       AllowFiltering="false">
                                                   </telerik:GridBoundColumn>
                                                   <telerik:GridBoundColumn DataField="Country" UniqueName="Country" HeaderText="Country"
                                                       AllowFiltering="false">
                                                   </telerik:GridBoundColumn>
                                                   <telerik:GridBoundColumn DataField="Phone" UniqueName="Phone" HeaderText="Phone"
                                                       AllowFiltering="false">
                                                   </telerik:GridBoundColumn>
                                                   <telerik:GridButtonColumn ConfirmText="Delete this Address?" ConfirmDialogType="RadWindow"
                                                       ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" />
                                               </Columns>
                                               <EditFormSettings EditFormType="Template" InsertCaption="Add New Address" CaptionDataField="UserID"
                                                   FormMainTableStyle-Font-Size="Medium" PopUpSettings-Modal="false">
                                                   <FormTemplate>
                                                       <table>
                                                           <tr style="display: <%# (Container is GridEditFormInsertItem) ? "" : "none" %>;">
                                                               <td>
                                                                   Address Type
                                                               </td>
                                                               <td>
                                                                   <telerik:RadComboBox DataTextField="Name" DataValueField="ID" ID="rcb_AddressTypes"
                                                                       runat="server" DataSourceID="EntityDataSource_AddressTypes" SelectedValue='<%#Bind("AddressTypeID") %>'>
                                                                   </telerik:RadComboBox>
                                                               </td>
                                                           </tr>
                                                           <tr>
                                                               <td>
                                                                   Street No
                                                               </td>
                                                               <td>
                                                                   <telerik:RadTextBox ID="rgDetail_tb_StreetNum" runat="server" Width="250px" MaxLength="255"
                                                                       Text='<%#Bind("StreetNum") %>' />
                                                               </td>
                                                           </tr>
                                                           <tr>
                                                               <td>
                                                                   Street Name
                                                               </td>
                                                               <td>
                                                                   <telerik:RadTextBox ID="rgDetail_tb_StreetName" runat="server" Width="250px" MaxLength="255"
                                                                       Text='<%#Bind("StreetName") %>' />
                                                               </td>
                                                           </tr>
                                                           <tr>
                                                               <td>
                                                                   Suit No
                                                               </td>
                                                               <td>
                                                                   <telerik:RadTextBox ID="rgDetail_tb_SuiteNo" runat="server" Width="250px" MaxLength="255"
                                                                       Text='<%#Bind("SuiteNo") %>' />
                                                               </td>
                                                           </tr>
                                                           <tr>
                                                               <td>
                                                                   City
                                                               </td>
                                                               <td>
                                                                   <telerik:RadTextBox ID="rgDetail_tb_CityName" runat="server" Width="250px" MaxLength="255"
                                                                       Text='<%#Bind("CityName") %>' />
                                                               </td>
                                                           </tr>
                                                           <tr>
                                                               <td>
                                                                   Province / State
                                                               </td>
                                                               <td>
                                                                   <telerik:RadTextBox ID="rgDetail_tb_State_Province" runat="server" Width="250px"
                                                                       MaxLength="255" Text='<%#Bind("State_Province") %>' />
                                                               </td>
                                                           </tr>
                                                           <tr>
                                                               <td>
                                                                   Country
                                                               </td>
                                                               <td>
                                                                   <telerik:RadTextBox ID="rgDetail_tb_Country" runat="server" Width="250px" MaxLength="255"
                                                                       Text='<%#Bind("Country") %>' />
                                                               </td>
                                                           </tr>
                                                           <tr>
                                                               <td>
                                                                   Phone
                                                               </td>
                                                               <td>
                                                                   <telerik:RadTextBox ID="rgDetail_tb_Phone" runat="server" Width="250px" MaxLength="255"
                                                                       Text='<%#Bind("Phone") %>' />
                                                               </td>
                                                           </tr>
                                                           <tr style="display: <%# (Container is GridEditFormInsertItem) ? "" : "none" %>;">
                                                               <td>
                                                                   Phone2
                                                               </td>
                                                               <td>
                                                                   <telerik:RadTextBox ID="rgDetail_tb_Phone2" runat="server" Width="250px" MaxLength="255"
                                                                       Text='<%#Bind("Phone2") %>' />
                                                               </td>
                                                           </tr>
                                                           <tr style="display: <%# (Container is GridEditFormInsertItem) ? "" : "none" %>;">
                                                               <td>
                                                                   Fax
                                                               </td>
                                                               <td>
                                                                   <telerik:RadTextBox ID="rgDetail_tb_Fax" runat="server" Width="250px" MaxLength="255"
                                                                       Text='<%#Bind("Fax") %>' />
                                                               </td>
                                                           </tr>
                                                           <tr style="display: <%# (Container is GridEditFormInsertItem) ? "" : "none" %>;">
                                                               <td>
                                                                   WebsiteURL
                                                               </td>
                                                               <td>
                                                                   <telerik:RadTextBox ID="rgDetail_tb_WebsiteURL" runat="server" Width="250px" MaxLength="255"
                                                                       Text='<%#Bind("WebsiteURL") %>' />
                                                               </td>
                                                           </tr>
                                                           <tr style="display: <%# (Container is GridEditFormInsertItem) ? "" : "none" %>;">
                                                               <td>
                                                                   Postal Code
                                                               </td>
                                                               <td>
                                                                   <telerik:RadTextBox ID="rgDetail_tb_PostalCode" runat="server" Width="250px" MaxLength="255"
                                                                       Text='<%#Bind("PostalCode") %>' />
                                                               </td>
                                                           </tr>
                                                       </table>
                                                       <table>
                                                           <tr>
                                                               <td>
                                                                   <telerik:RadButton ID="rgD_rb_Update" runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'
                                                                       CausesValidation="true" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' />
                                                                   <telerik:RadButton ID="rgD_rb_Cancel" runat="server" CommandName="Cancel" CausesValidation="false"
                                                                       Text="Cancel" />
                                                               </td>
                                                           </tr>
                                                       </table>
                                                   </FormTemplate>
                                               </EditFormSettings>
                                           </telerik:GridTableView>
                                       </DetailTables>
                                       <EditFormSettings EditFormType="Template" InsertCaption="Add New Member" CaptionDataField="ID"
                                           FormMainTableStyle-Font-Size="Medium" PopUpSettings-Modal="false">
                                           <FormTemplate>
                                               <table>
                                                   <tr>
                                                       <td>
                                                           <asp:Label ID="lblRegisterAs" runat="server" Text="Register as:">
                                                           </asp:Label>
                                                       </td>
                                                       <td style="width: 150px;">
                                                           <asp:RadioButtonList ID="rdbtnRegisterAs" runat="server" RepeatDirection="Horizontal"
                                                               Enabled='<%# (Container is GridEditFormInsertItem) ? true : false %>'>
                                                               <asp:ListItem Text="Bidder" Selected="True"></asp:ListItem>
                                                               <asp:ListItem Text="Seller"></asp:ListItem>
                                                           </asp:RadioButtonList>
                                                       </td>
                                                   </tr>
                                                   <tr>
                                                       <td>
                                                           <asp:Label ID="FirstName" runat="server" Text="First Name:">
                                                           </asp:Label>
                                                       </td>
                                                       <td>
                                                           <telerik:RadTextBox ID="txtFirstName" Text='<%# Bind( "FirstName") %>' runat="server">
                                                           </telerik:RadTextBox>
                                                           <asp:RequiredFieldValidator ID="rfvFirstName" runat="server" ControlToValidate="txtFirstName"
                                                               Text="*" CssClass="validatorColor">
                                                           </asp:RequiredFieldValidator>
                                                       </td>
                                                       <td>
                                                           <asp:Label ID="LastName" runat="server" Text="Last Name:">
                                                           </asp:Label>
                                                       </td>
                                                       <td style="width: 250px;">
                                                           <telerik:RadTextBox ID="txtLastName" Text='<%# Bind( "LastName") %>' runat="server">
                                                           </telerik:RadTextBox>
                                                           <asp:RequiredFieldValidator ID="rfvLastName" runat="server" ControlToValidate="txtLastName"
                                                               Text="*" CssClass="validatorColor">
                                                           </asp:RequiredFieldValidator>
                                                       </td>
                                                   </tr>
                                                   <tr>
                                                       <td>
                                                           <asp:Label ID="lblPrimaryEmail" runat="server" Text="Primary Email:">
                                                           </asp:Label>
                                                       </td>
                                                       <td>
                                                           <telerik:RadTextBox ID="txtPrimaryEmail" Text='<%# Bind( "PrimaryEmailAddress") %>'
                                                               runat="server" Enabled='<%# (Container is GridEditFormInsertItem) ? true : false %>'>
                                                           </telerik:RadTextBox>
                                                           <asp:RequiredFieldValidator ID="rfvPrimaryEmail" runat="server" ControlToValidate="txtPrimaryEmail"
                                                               CssClass="validatorColor" Text="*">
                                                           </asp:RequiredFieldValidator>
                                                           <asp:RegularExpressionValidator ID="revEmailValid" runat="server" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                                               ControlToValidate="txtPrimaryEmail" Display="Dynamic" ErrorMessage="Invalid Format"
                                                               CssClass="validatorColor"></asp:RegularExpressionValidator>
                                                       </td>
                                                       <td>
                                                           <asp:Label ID="lblAlternateEmail" runat="server" Text="Alternate Email:">
                                                           </asp:Label>
                                                       </td>
                                                       <td>
                                                           <telerik:RadTextBox ID="txtEmail" runat="server" Text='<%# Bind( "AlternateEmail") %>'>
                                                           </telerik:RadTextBox>
                                                           <asp:RegularExpressionValidator ID="revAlternateEmail" runat="server" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                                               ControlToValidate="txtEmail" Display="Dynamic" ErrorMessage="Invalid Format"
                                                               CssClass="validatorColor"></asp:RegularExpressionValidator>
                                                       </td>
                                                   </tr>
                                                   <tr visible='<%# (Container is GridEditFormInsertItem) ? true : false %>' runat="server"
                                                       id="tr_Passwords">
                                                       <td>
                                                           <asp:Label ID="lblPassword" runat="server" Text="Password:">
                                                           </asp:Label>
                                                       </td>
                                                       <td>
                                                           <telerik:RadTextBox ID="txtPassword" runat="server" TextMode="Password">
                                                           </telerik:RadTextBox>
                                                           <asp:RequiredFieldValidator ID="rfvPassword" runat="server" ControlToValidate="txtPassword"
                                                               CssClass="validatorColor" Text="*">
                                                           </asp:RequiredFieldValidator>
                                                       </td>
                                                       <td>
                                                           <asp:Label ID="lblConfirm" runat="server" Text="Confirm:">
                                                           </asp:Label>
                                                       </td>
                                                       <td>
                                                           <telerik:RadTextBox ID="txtConfirm" runat="server" TextMode="Password">
                                                           </telerik:RadTextBox>
                                                           <asp:RequiredFieldValidator ID="rfvConfirm" runat="server" ControlToValidate="txtConfirm"
                                                               CssClass="validatorColor" Text="*" Display="Dynamic">
                                                           </asp:RequiredFieldValidator>
                                                           <asp:CompareValidator ID="cvPassword" runat="server" ControlToValidate="txtConfirm"
                                                               ControlToCompare="txtPassword" Text="Password Mismatch" CssClass="validatorColor"></asp:CompareValidator>
                                                       </td>
                                                   </tr>
                                                   <tr>
                                                       <td>
                                                           <asp:Label ID="lblPhoneNo" runat="server" Text="Phone No.:">
                                                           </asp:Label>
                                                       </td>
                                                       <td>
                                                           <telerik:RadTextBox ID="txtPhoneNo" Text='<%# Bind( "Phone") %>' runat="server">
                                                           </telerik:RadTextBox>
                                                       </td>
                                                       <td>
                                                           <asp:Label ID="lblMobileNo" runat="server" Text="Mobile No.:">
                                                           </asp:Label>
                                                       </td>
                                                       <td>
                                                           <telerik:RadTextBox ID="txtMobileNo" runat="server" Text='<%# Bind( "Phone2") %>'>
                                                           </telerik:RadTextBox>
                                                       </td>
                                                   </tr>
                                               </table>
                                               <table>
                                                   <tr>
                                                       <td style="width: 220px;">
                                                           <asp:CheckBox ID="chkIsLock" runat="server" Text="IsLock" Checked='<%#Eval("islock") == null ? false : (Eval("islock").ToString()=="True"? true : false)%>' />
                                                       </td>
                                                   </tr>
                                                   <tr>
                                                       <td>
                                                           <telerik:RadButton ID="rgM_rb_Update" runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'
                                                               CausesValidation="true" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' />
                                                           <telerik:RadButton ID="rgM_rb_Cancel" runat="server" CommandName="Cancel" CausesValidation="false"
                                                               Text="Cancel" />
                                                       </td>
                                                   </tr>
                                               </table>
                                           </FormTemplate>
                                       </EditFormSettings>
                                   </MasterTableView>
                               </telerik:RadGrid>
                               <asp:EntityDataSource ID="EntityDataSource_AllMembers" runat="server" ConnectionString="name=My_db"
                                   DefaultContainerName="My_db" EntitySetName="Members" OrderBy="it.[ID],it.[FirstName]"
                                   EntityTypeFilter="" EnableUpdate="True" EnableDelete="True" EnableInsert="True"
                                   OnInserting="OnAllMembersInserting" OnInserted="OnAllMembersInserted" OnUpdating="OnAllMembersUpdating"
                                   OnUpdated="OnAllMembersUpdated" OnDeleting="OnAllMembersDeleting" OnDeleted="OnAllMembersDeleted"
                                   OnSelecting="OnAllMembersSelecting">
                               </asp:EntityDataSource>
                               <asp:EntityDataSource ID="EntityDataSource_Address" runat="server" ConnectionString="name=My_db"
                                   DefaultContainerName="My_db" EntitySetName="MemberAddresses" OrderBy="it.[ID]"
                                   EnableUpdate="True" EnableDelete="True" EnableInsert="True" Where="it.[UserID] = @UserID"
                                   OnInserting="OnAddressInserting" OnInserted="OnAddressInserted" AutoGenerateWhereClause="True"
                                   EnableFlattening="False">
                                   <WhereParameters>
                                       <asp:Parameter Name="UserID" DbType="Guid" />
                                   </WhereParameters>
                               </asp:EntityDataSource>
                               <asp:EntityDataSource ID="EntityDataSource_AddressTypes" runat="server" ConnectionString="name=My_db"
                                   DefaultContainerName="My_db" EntitySetName="MemberAddressTypes" EnableInsert="True"
                                   EnableFlattening="False">
                               </asp:EntityDataSource>

code behind all events code is follows
protected void OnAllMembersSelecting(object sender, EntityDataSourceSelectingEventArgs e)
        {
            e.DataSource.Where = "it.RoleName = 'Bidders' or it.RoleName = 'Sellers'";
        }
 
        protected void OnAllMembersInserting(object sender, EntityDataSourceChangingEventArgs e)
        {
        }
 
        protected void OnAllMembersInserted(object sender, EntityDataSourceChangedEventArgs e)
        {          
        }
 
        protected void OnAllMembersUpdating(object sender, EntityDataSourceChangingEventArgs e)
        {
        }
 
        protected void OnAllMembersUpdated(object sender, EntityDataSourceChangedEventArgs e)
        {
        }
 
        protected void OnAllMembersDeleting(object sender, EntityDataSourceChangingEventArgs e)
        {        
        }
 
        protected void OnAllMembersDeleted(object sender, EntityDataSourceChangedEventArgs e)
        {        
        }
 
        protected void OnAddressInserting(object sender, EntityDataSourceChangingEventArgs e)
        {
        }
 
        protected void OnAddressInserted(object sender, EntityDataSourceChangedEventArgs e)
        {        
        }

can any one please tell me what is the issue and why filter event is not working

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 13 Mar 2012, 12:57 PM
Hello,

Here are some forum threads discussing similar scenario. Hope this helps you.
Filtering with EntityDataSource
RadGrid and EntityDataSource

Thanks,
Princy.
Tags
General Discussions
Asked by
kd
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or