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

EnableHeaderContextFilterMenu Filter Strange after rebind Grid

1 Answer 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
chameleon
Top achievements
Rank 1
chameleon asked on 13 Nov 2015, 06:29 AM
<telerik:RadGrid ID="rgridUserList" runat="server" GridLines="None" OnNeedDataSource="rgridUserList_NeedDataSource"
                   AllowSorting="true" EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true"
                   AllowFilteringByColumn="true" EnableLinqExpressions="false" OnItemCommand="rgridUserList_ItemCommand"
                   Skin="Telerik" OnItemDataBound="rgridUserList_ItemDataBound">
                   <ClientSettings>
                       <Selecting AllowRowSelect="True"></Selecting>
                   </ClientSettings>
                   <GroupingSettings CaseSensitive="false"></GroupingSettings>
                   <MasterTableView DataKeyNames="UserID" CommandItemDisplay="Top" IsFilterItemExpanded="false"
                       EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true" AllowFilteringByColumn="true">
                       <Columns>
                           <telerik:GridTemplateColumn HeaderText="No." UniqueName="Number" ItemStyle-CssClass="NumberColomn">
                               <HeaderStyle Width="30px" HorizontalAlign="Center" />
                               <ItemStyle HorizontalAlign="Center" />
                               <ItemTemplate>
                                   <asp:Label ID="lblGridNumber" runat="server" Text='<%# (rgridUserList.PageSize*rgridUserList.CurrentPageIndex)+ Container.ItemIndex + 1 %>'></asp:Label>
                               </ItemTemplate>
                           </telerik:GridTemplateColumn>
                           <telerik:GridTemplateColumn HeaderText="User Name" UniqueName="UserName" SortExpression="UserName"
                               CurrentFilterFunction="Contains" DataField="UserName" >
                               <HeaderStyle HorizontalAlign="Center" />
                               <ItemStyle HorizontalAlign="Left" />
                               <ItemTemplate>
                                   <asp:HyperLink ID="hlUserName" Font-Underline="true" runat="server"><%# DataBinder.Eval(Container, "DataItem.UserName") %></asp:HyperLink>
                               </ItemTemplate>
                           </telerik:GridTemplateColumn>
                           <telerik:GridTemplateColumn HeaderText="Full Name" UniqueName="FullName" SortExpression="FullName"
                               CurrentFilterFunction="Contains" DataField="FullName">
                               <HeaderStyle HorizontalAlign="Center" />
                               <ItemStyle HorizontalAlign="Left" />
                               <ItemTemplate>
                                   <asp:Label ID="lblFullName" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.FullName") %>'></asp:Label>
                               </ItemTemplate>
                           </telerik:GridTemplateColumn>
                           <telerik:GridTemplateColumn HeaderText="Email" UniqueName="Email" SortExpression="Email"
                               CurrentFilterFunction="Contains" DataField="Email">
                               <HeaderStyle HorizontalAlign="Center" />
                               <ItemStyle HorizontalAlign="Left" />
                               <ItemTemplate>
                                   <asp:Label ID="lblEmail" SkinID="EmailColor" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Email") %>'></asp:Label>
                               </ItemTemplate>
                           </telerik:GridTemplateColumn>
                           <telerik:GridTemplateColumn HeaderText="User Group" UniqueName="UserGroupItem" SortExpression="UserGroupItem"
                               DataField="UserGroupItem" CurrentFilterFunction="Contains" >
                               <HeaderStyle HorizontalAlign="Center" />
                               <ItemStyle HorizontalAlign="Left" />
                               <ItemTemplate>
                                   <asp:Label ID="lblUserGroup" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.UserGroupItem") %>'></asp:Label>
                               </ItemTemplate>
                           </telerik:GridTemplateColumn>
                           <telerik:GridTemplateColumn HeaderText="Is Active" UniqueName="IsActive" SortExpression="IsActive"
                               HeaderStyle-HorizontalAlign="Center" >
                               <ItemStyle HorizontalAlign="Center" />
                               <ItemTemplate>
                                   <asp:CheckBox ID="cbIsActive" runat="server" Enabled="false" Checked='<%# DataBinder.Eval(Container, "DataItem.IsActive") %>' />
                               </ItemTemplate>
                           </telerik:GridTemplateColumn>
                           <telerik:GridTemplateColumn HeaderText="Created By" UniqueName="CreatedBy" SortExpression="CreatedBy"
                                HeaderStyle-HorizontalAlign="Center" DataField="CreatedByName" CurrentFilterFunction="Contains">
                               <ItemStyle HorizontalAlign="Center" />
                               <ItemTemplate>
                                   <asp:Label ID="lblCreatedBy" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.CreatedByName") %>'></asp:Label>
                               </ItemTemplate>
                           </telerik:GridTemplateColumn>
                           <telerik:GridTemplateColumn HeaderText="Last Access" UniqueName="LastAccess" SortExpression="LastAccess"
                                HeaderStyle-HorizontalAlign="Center" DataField="LastAccess" CurrentFilterFunction="Contains">
                               <ItemStyle HorizontalAlign="Center" />
                               <ItemTemplate>
                                   <asp:Label ID="lblLastAccess" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.LastAccess","{0:dd-MM-yyyy hh:mm tt}") %>' />
                               </ItemTemplate>
                           </telerik:GridTemplateColumn>
                           <telerik:GridTemplateColumn HeaderText="Need Approval" Visible="false" UniqueName="IsNeedApproval"
                               HeaderStyle-HorizontalAlign="Center" SortExpression="IsNeedApproval">
                               <ItemStyle HorizontalAlign="Center" />
                               <ItemTemplate>
                                   <asp:CheckBox ID="cbIsNeedApproval" runat="server" Checked='<%# DataBinder.Eval(Container, "DataItem.IsNeedApproval") %>'>
                                   </asp:CheckBox>
                               </ItemTemplate>
                           </telerik:GridTemplateColumn>
                           <telerik:GridTemplateColumn HeaderText="Action" UniqueName="Action">
                               <HeaderStyle Width="100px" HorizontalAlign="Center" />
                               <ItemStyle HorizontalAlign="Center" />
                               <ItemTemplate>
                                   <asp:ImageButton ID="btnEdit" runat="server" SkinID="Edit" CommandName="Edit" Visible='<%# !(bool)DataBinder.Eval(Container, "DataItem.IsNeedApproval") %>' />
                                   <asp:ImageButton ID="btnDelete" runat="server" SkinID="Delete" CommandName="Delete"
                                       Visible='<%# !(bool)DataBinder.Eval(Container, "DataItem.IsNeedApproval") %>'
                                       OnClientClick="javascript:return confirm('Are you sure want to delete?')" />
                                   <asp:Label ID="lblNeedApproval" runat="server" Text='Need Approval' Visible='<%# DataBinder.Eval(Container, "DataItem.IsNeedApproval") %>'
                                       ForeColor="Red"></asp:Label>
                               </ItemTemplate>
                           </telerik:GridTemplateColumn>
                       </Columns>
                       <CommandItemTemplate>
                           <telerik:RadToolBar ID="RadTBUser" runat="server" SkinID="NewAndExport" />
                       </CommandItemTemplate>
                       <ExpandCollapseColumn Visible="False" Resizable="False">
                           <HeaderStyle Width="20px" />
                       </ExpandCollapseColumn>
                       <CommandItemSettings ExportToPdfText="Export to PDF" />
                       <RowIndicatorColumn Visible="False">
                           <HeaderStyle Width="20px" />
                       </RowIndicatorColumn>
                       <EditFormSettings>
                           <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                           </EditColumn>
                       </EditFormSettings>
                       <PagerStyle AlwaysVisible="True" Mode="NextPrevNumericAndAdvanced"></PagerStyle>
                   </MasterTableView>
                   <HeaderStyle HorizontalAlign="Center" />
                   <FilterMenu EnableImageSprites="False">
                   </FilterMenu>
                   <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                   </HeaderContextMenu>
               </telerik:RadGrid>

 

 

That is my code..

Scenario:

-I have 12 records ( 0.12Records.JPG)

-I try to filter (1.Search.JPG) The filter is fine. 

-Then I click Search button to rebind grid's datasource (2.Search.JPG)

-The right click filter on header , the text is cleared. But, the records not showing all records. I try to type something, the filter is not working.

-After I click Search Button (again) the filter is fine again.

 

What inside button search is:

private void BindGrid()
   {
       try
       {
           sessUserCollection = null;
           rgridUserList.Rebind();
       }
       catch (Exception Ex)
       {
           throw Ex;
       }
   }

 

So, the problem is when I click once the search button (rebind grid) the filter is crippled.

I need to click it twice, so the database hitted twice.

 

 

 

Any ways to solve this problem?
Am I missing something?

 

 

1 Answer, 1 is accepted

Sort by
0
chameleon
Top achievements
Rank 1
answered on 19 Nov 2015, 06:48 AM
anyone?
Tags
Grid
Asked by
chameleon
Top achievements
Rank 1
Answers by
chameleon
Top achievements
Rank 1
Share this question
or