radgrid combobox javascript filter not working after filtering first time

2 posts, 0 answers
  1. Don
    Don avatar
    3 posts
    Member since:
    Dec 2012

    Posted 14 Aug 2013 Link to this post

    My combobox filter only works the first time it is selected.
    I am using the same user control on the page multiple times so I need a unique javascript function name

    <telerik:RadGrid ID="grvProjectSummary" runat="server"
        AllowAutomaticDeletes="True" AllowFilteringByColumn="True" AllowPaging="True"
        AllowSorting="True" AutoGenerateColumns="False" CellSpacing="0"
        CssClass="eGrantsGroupBox" GridLines="None"
        PageSize="25" Skin="Office2010Blue" Width="100%">
        <HeaderStyle CssClass="eGrantsGridHeader" />
        <ItemStyle CssClass="eGrantsTableRow" />
        <AlternatingItemStyle CssClass="eGrantsTableAltRow" />
        <GroupingSettings CaseSensitive="false" />
        <MasterTableView CommandItemDisplay="Bottom" DataKeyNames="GrantProjectPK, AgencyFK"
            ShowHeadersWhenNoRecords="true" TableLayout="Fixed">
            <CommandItemSettings ExportToPdfText="Export to PDF"
                ShowAddNewRecordButton="False" ShowExportToCsvButton="True"
                ShowExportToExcelButton="True" ShowExportToPdfButton="True"
                ShowExportToWordButton="True" ShowRefreshButton="True" />
            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
            </RowIndicatorColumn>
            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
            </ExpandCollapseColumn>
            <Columns>

                <telerik:GridNumericColumn Aggregate="Count" AllowFiltering="False"
                    DataField="GrantProjectPK" DecimalDigits="2"
                    FilterControlAltText="Filter GrantProjectPKColumn column" HeaderText="&nbsp;"
                    ReadOnly="True" ShowFilterIcon="False" SortExpression="GrantProjectPK"
                    UniqueName="GrantProjectPKColumn">
                    <HeaderStyle Width="40px" />
                    <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="40px" />
                </telerik:GridNumericColumn>

                <telerik:GridBoundColumn AutoPostBackOnFilter="true" Visible="true"
                    CurrentFilterFunction="Contains" DataField="AgencyName"
                    FilterControlWidth="100px" HeaderText="Agency/LEA" ShowFilterIcon="true"
                    SortExpression="AgencyName"
                    UniqueName="AgencyNameColumn">
                    <HeaderStyle HorizontalAlign="Left" Width="180px" />
                    <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="180px" />
                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn AutoPostBackOnFilter="true" Visible="false"
                    CurrentFilterFunction="Contains" DataField="GrantProgramTypeTitle"
                    FilterControlWidth="60px" HeaderText="Program Title" ShowFilterIcon="true"
                    SortExpression="GrantProgramTypeTitle"
                    UniqueName="GrantProgramTypeTitleColumn">
                    <HeaderStyle HorizontalAlign="Left" Width="180px" />
                    <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="180px" />
                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn UniqueName="columnAUNumber" AutoPostBackOnFilter="true"
                    ReadOnly="true" CurrentFilterFunction="Contains" DataField="AUNumber" HeaderText="AUN"
                    ShowFilterIcon="true" SortExpression="AUNumber" FilterControlWidth="60px">
                    <HeaderStyle Width="100px"></HeaderStyle>
                    <ItemStyle Width="100px" HorizontalAlign="Left" />
                </telerik:GridBoundColumn>

                <telerik:GridTemplateColumn DataField="StepName" HeaderText="Workflow Step" UniqueName="StepName" SortExpression="StepName">
                    <HeaderStyle HorizontalAlign="Left" Width="120px" />
                    <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="120px" />
                    <FilterTemplate>
                        <telerik:RadComboBox ID="rcmbStepFilter" DataSourceID="SqlDataSource3" Width="110px" Skin="Office2010Blue"
                            DataTextField="StepName"
                            DataValueField="StepName" AppendDataBoundItems="true"
                            SelectedValue='<%# TryCast(Container, GridItem).OwnerTableView.GetColumn("StepName").CurrentFilterValue%>'
                            runat="server">
                            <Items>
                                <telerik:RadComboBoxItem />
                            </Items>
                        </telerik:RadComboBox>
                        <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
                            <script type="text/javascript">
                                function SelectedIndexChanged_<%= ClientID %>(sender, args) {
                                    var tableView = $find("<%# TryCast(Container, GridItem).OwnerTableView.ClientID %>");
                                    tableView.filter("StepName", args.get_item().get_value(), "EqualTo");
                                }
                            </script>
                        </telerik:RadScriptBlock>
                    </FilterTemplate>
                    <ItemTemplate>
                        <%# Eval("StepName")%>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>

                <telerik:GridDateTimeColumn UniqueName="columnSubmitDate"
                    DataField="SubmitDate.date" HeaderText="Submit Date" FilterControlWidth="80px"
                    SortExpression="SubmitDate.date" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy}"
                    ShowFilterIcon="true" CurrentFilterFunction="EqualTo">
                    <HeaderStyle HorizontalAlign="Left" Width="120px" />
                    <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="120px" />
                </telerik:GridDateTimeColumn>
                            
                <telerik:GridBoundColumn AutoPostBackOnFilter="true"
                    CurrentFilterFunction="Contains" DataField="LastName" AllowFiltering="false"
                    FilterControlWidth="60px" EmptyDataText="Unassigned"
                    HeaderText="Assigned To" ShowFilterIcon="false" SortExpression="LastName"
                    UniqueName="AssignedToColumn">
                    <HeaderStyle HorizontalAlign="Left" Width="100px" />
                    <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="100px" />
                </telerik:GridBoundColumn>

                <telerik:GridButtonColumn UniqueName="SelectCommandColumnNoAjax"
                    ButtonType="ImageButton" Text="Assign Reviewers"
                    ImageUrl="~/images/users_add.png"
                    CommandArgument="" CommandName="AssignUsers"
                    ItemStyle-HorizontalAlign="Center">
                    <HeaderStyle Width="40px"></HeaderStyle>
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="40px"></ItemStyle>
                </telerik:GridButtonColumn>

                <telerik:GridButtonColumn ButtonType="ImageButton" CommandArgument=""
                    CommandName="SEL" ImageUrl="~/images/select_program_sm.gif" Text="View Program"
                    UniqueName="SelectCommandColumn">
                    <HeaderStyle Width="40px" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="40px" />
                </telerik:GridButtonColumn>

                <telerik:GridButtonColumn ButtonType="ImageButton" CommandArgument=""
                    CommandName="REVIEW" ImageUrl="~/images/review.png" Text="Review"
                    UniqueName="ReviewCommandColumn">
                    <HeaderStyle Width="40px" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="40px" />
                </telerik:GridButtonColumn>

                <telerik:GridNumericColumn Aggregate="Count" AllowFiltering="False"
                    DataField="ProjectStatusWorkflowRouteStepPK"
                    HeaderText="&nbsp;" ReadOnly="True" ShowFilterIcon="False" Visible="False"
                    UniqueName="ProjectStatusWorkflowRouteStepPKColumn">
                    <HeaderStyle Width="40px" />
                    <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="40px" />
                </telerik:GridNumericColumn>

            </Columns>
        </MasterTableView>
        <ClientSettings>
            <Resizing AllowColumnResize="True" />
        </ClientSettings>
        <FilterMenu EnableEmbeddedSkins="False" EnableImageSprites="False">
        </FilterMenu>
        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"
            EnableEmbeddedSkins="False">
        </HeaderContextMenu>
    </telerik:RadGrid>

        Private Sub SetFilterComboScript()
            For Each filterItem As GridFilteringItem In grvProjectSummary.MasterTableView.GetItems(GridItemType.FilteringItem)
                Dim rcmbStepFilter As RadComboBox = DirectCast(filterItem.FindControl("rcmbStepFilter"), RadComboBox)
                rcmbStepFilter.OnClientSelectedIndexChanged = "SelectedIndexChanged_" + Me.ClientID
            Next
        End Sub

        Private Sub grvProjectSummary_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grvProjectSummary.NeedDataSource
            _ProjectWorkflowRouteType = ViewState("ProjectWorkflowRouteType")
            Dim myFilter As Integer = ViewState("myFilter")
            Dim GrantProgramFK As Integer = CInt(ddlGrantPrograms.SelectedValue)
            Dim UserFK As Integer = CInt(Session(eGrantsConst_Session.USER_LOGIN_ID))
            If HttpContext.Current.User.IsInRole(eGrantsConst_Role.BUREAU_REVIEW_MANAGER) Then
                If ddlReviewers.SelectedValue > 0 Then
                    UserFK = ddlReviewers.SelectedValue
                End If
            End If
            grvProjectSummary.DataSource = BLL.BusObjects.ReviewBO.GetReviewWorkQueuProjectsByBureauFKGrantProgramYearFKRouteTypeFKUserFK(Session(eGrantsConst_Session.SELECTED_PROGRAM_YEAR), _
                                                                                                                                            CInt(Session(eGrantsConst_Session.SELECTED_BUREAU_ID)), _
                                                                                                                                            CInt(Session(eGrantsConst_Session.SELECTED_PROGRAM_YEAR_ID)), _
                                                                                                                                            _ProjectWorkflowRouteType, _
                                                                                                                                            UserFK, _
                                                                                                                                            GrantProgramFK, _
                                                                                                                                            myFilter)
            SetFilterComboScript()
        End Sub
  2. Don
    Don avatar
    3 posts
    Member since:
    Dec 2012

    Posted 15 Aug 2013 Link to this post

    Solved:

        Private Sub grvProjectSummary_DataBound(sender As Object, e As EventArgs) Handles grvProjectSummary.DataBound
            SetFilterComboScript()
        End Sub
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top