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

Context Menu Filtering - Filter disappears from menu

2 Answers 19 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 16 Oct 2014, 04:51 PM
When utilizing the context menu filtering it works fine for adding 1 filter. If you do another action, like sort or add another filter, it keeps the previous filter but doesn't show it in the menu. If you click "Clear Filter" it does clear the filter that you don't see and refreshes the grid as you would expect. It doesn't do this in the Telerik demo, so I'm thinking there's something wrong with my code or there's been a fix since the Telerik build we're using (2013.2.717.35). Any ideas? Thanks.

<
telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        var cancelAjax = false;
 
        function RequestStart(sender, eventArgs) {
            if ((eventArgs.get_eventTarget() == "ctl00$ContentPlaceHolder1$ShipClassGridView$ctl00$ctl02$ctl00$WirsRadToolBar") &&
           (cancelAjax)) {
                eventArgs.set_enableAjax(false);
            }
            else eventArgs.set_enableAjax(true);
        }
 
        function OnClientButtonClickingHandler(sender, eventArgs) {
            if (eventArgs.get_item().get_value() == "NoAjax") {
                cancelAjax = true;
            }
        }
 
        function ShowColumnHeaderMenu(ev, columnName) {
            var grid = window.$find("<%=ShipClassGridView.ID %>");
            var columns = grid.get_masterTableView().get_columns();
 
            for (var i = 0; i < columns.length; i++) {
                if (columns[i].get_uniqueName() == columnName) {
                    columns[i].showHeaderMenu(ev, 75, 20);
                }
            }
        }
    </script>
</telerik:RadCodeBlock>
<telerik:RadGrid ID="ShipClassGridView" runat="server" AllowAutomaticDeletes="false"
    EnableViewState="false" Visible="true" AllowAutomaticInserts="false" AllowAutomaticUpdates="false"
    EnableAJAX="true" GroupingEnabled="false" Skin="WIRS" EnableEmbeddedSkins="false"
    GridLines="None" OnItemCommand="ShipClassGridView_ItemCommand" OnNeedDataSource="ShipClassGridView_NeedDataSource"
    GroupingSettings-CaseSensitive="false" AllowSorting="True" EnableHeaderContextMenu="true"
    EnableHeaderContextFilterMenu="true" AllowFilteringByColumn="true" EnableLinqExpressions="false"
    OnItemDataBound="ShipClassGridView_OnItemDataBound" AutoGenerateColumns="False">
    <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
        <Excel Format="Biff" />
    </ExportSettings>
    <MasterTableView DataKeyNames="Id" IsFilterItemExpanded="false" AllowFilteringByColumn="true"
        CommandItemDisplay="Top" EnableNoRecordsTemplate="true">
        <NoRecordsTemplate>
            No results found for the selected ship class.</NoRecordsTemplate>
        <CommandItemTemplate>
            <telerik:RadToolBar runat="server" EnableEmbeddedSkins="false" Skin="WIRS" ID="WirsRadToolBar"
                Width="100%" OnClientButtonClicking="OnClientButtonClickingHandler" OnButtonClick="WirsRadToolBar_ButtonClick">
                <Items>
                    <telerik:RadToolBarButton Text="Export to Excel" Value="NoAjax" CommandName="ExportExcel"
                        ImageUrl="../images/Toolbar/xls.gif" />
                    <telerik:RadToolBarButton Text="Export to PDF" Value="NoAjax" CommandName="ExportPdf"
                        ImageUrl="../images/Toolbar/pdf.gif" />
                </Items>
            </telerik:RadToolBar>
        </CommandItemTemplate>
        <CommandItemSettings ShowAddNewRecordButton="false" ShowExportToPdfButton="true" />
        <Columns>
            <telerik:GridBoundColumn DataField="Id" HeaderText="Id" SortExpression="Id" AllowFiltering="false"
                Visible="false" />
            <telerik:GridTemplateColumn HeaderText="Hull Number" DataField="Hull" DataType="System.String"
                SortExpression="Hull">
                <ItemTemplate>
                    <asp:Label ID="HullLabel" runat="server" Text='<%# Eval("Hull") %>' Style="position: relative;
                        top: -3px;"></asp:Label>
                    <asp:Image ID="ImageHullNo" runat="server" ImageUrl="../images/New/eo_web.ashx.gif"
                        Visible="false" />
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name" />
            <telerik:GridDateTimeColumn HeaderText="Last Modified" DataField="LastUpdateDate"
                SortExpression="LastUpdateDate" DataFormatString="{0:d}" UniqueName="LastUpdateDate"
                PickerType="None" />
            <telerik:GridBoundColumn DataField="ModifiedByDisplayName" HeaderText="Last Modified By"
                SortExpression="ModifiedByDisplayName" />
            <telerik:GridNumericColumn HeaderText="Total Records" DataField="WirsRowCount" SortExpression="WirsRowCount"
                UniqueName="WirsRowCount" />
            <telerik:GridTemplateColumn AllowFiltering="false" HeaderText="Ship Status">
                <ItemTemplate>
                    <asp:Label ID="RecordStatusLbl" runat="server" />
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
    <ClientSettings EnableRowHoverStyle="true" Resizing-AllowColumnResize="true" AllowColumnsReorder="true" />
</telerik:RadGrid>

2 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 21 Oct 2014, 09:17 AM
Hi Mike,

The behavior you are observing is seen because the ViewState for RadGrid is disabled.
In order to enable the filter TextBoxes to persist their values try setting the EnableViewState property for RadGrid to true.

Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mike
Top achievements
Rank 1
answered on 21 Oct 2014, 02:56 PM
Thanks, I was finally able to find that's one of the actions that doesn't work when ViewState is disabled.
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Mike
Top achievements
Rank 1
Share this question
or