Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Grid > Initial Grid filter expression on being passed to DataBinding

Not answered Initial Grid filter expression on being passed to DataBinding

Feed from this thread
  • David avatar

    Posted on Feb 6, 2012 (permalink)

    For the following control definition, I am not getting an initial filter expression passed to the WCF GetDataAndCount method.  The initial filter expression is empty.  If I set a filter after the grid is loaded, then the call to GetDataAndCount is passed a filter expression.  I am following the example at http://www.telerik.com/help/aspnet-ajax/grid-applying-default-filter-on-initial-load.html.


    <telerik:RadGrid runat="server" ID="RadGrid1" AllowPaging="True" AllowSorting="True"
                AllowFilteringByColumn="True" PageSize="40" CellSpacing="0"
                GridLines="None" Skin="Office2010Blue" AutoGenerateColumns="False"
                EnableViewState="False" EnableLinqExpressions="false" >
                <MasterTableView DataKeyNames="ProductID" ClientDataKeyNames="ProductID"
                    EnableViewState="False" FilterExpression="([Staus] <> 'Closed')">
                    <PagerStyle Mode="NumericPages" />
                    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
                    <Columns>
                        <telerik:GridBoundColumn DataField="Number" HeaderText="Number" DataType="System.Int32" HeaderStyle-Width="50px">
                            <HeaderStyle Width="50px"></HeaderStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Type" HeaderText="Type" DataType="System.Int32" HeaderStyle-Width="75px">
                            <HeaderStyle Width="75px"></HeaderStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Subject" HeaderText="Subject" DataType="System.String" ItemStyle-Wrap="False" FilterControlWidth="150px">
                            <HeaderStyle Width="150px"></HeaderStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Status" HeaderText="Status" DataType="System.String" CurrentFilterFunction="NotEqualTo" CurrentFilterValue="Closed">
                            <HeaderStyle Width="75px"></HeaderStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Priority" HeaderText="Priority" DataType="System.String">
                            <HeaderStyle Width="75px"></HeaderStyle>
                        </telerik:GridBoundColumn>
                        <telerik:GridDateTimeColumn DataField="CreationDate" HeaderText="Creation Date" PickerType="None" DataType="System.DateTime" DataFormatString="{0:M/d/yyyy h:mm tt}" ItemStyle-Wrap="False">
                            <HeaderStyle Width="200px"></HeaderStyle>
                        </telerik:GridDateTimeColumn>
                    </Columns>

                    <EditFormSettings>
                        <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                    </EditFormSettings>

                    <PagerStyle Mode="NextPrevAndNumeric" />
                </MasterTableView>
                <ClientSettings>
                    <DataBinding SelectMethod="GetDataAndCount" Location="Ajax" SortParameterType="String" FilterParameterType="String">
                    </DataBinding>
                    <Selecting AllowRowSelect="True" />
                    <ClientEvents OnRowDataBound="rowBound" />
                </ClientSettings>
                <FilterMenu EnableImageSprites="False"></FilterMenu>
            </telerik:RadGrid>

    Reply

  • Tsvetina Tsvetina admin's avatar

    Posted on Feb 9, 2012 (permalink)

    Hello David,

    You can find sample code and project in the following forum post by my colleague. Try it out and let us know in case you have any further questions or concerns:

    http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-set-initial-sort-and-filter.aspx#1619903

    Kind regards,
    Tsvetina
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

  • David avatar

    Posted on Feb 9, 2012 (permalink)

    Thanks.  This code sample appears to get us 90% of the way there.  The issue that I am still having (and it is also an issue in the sample) is that the filter that is set in the grid as part of this script is not setting the filter type in the dropdown list of filters.  For example, when the user selects NotEqualTo in the filter list, that selection stays selected in the dropdown.  When the code sets the filter type, a filter is sent to the server, but the filter dropdown does not have the item selected in the drop down.

    How do we get the correct item selected in the filter dropdown so that the user knows what fitler type is being used?

    Reply

  • Tsvetina Tsvetina admin's avatar

    Posted on Feb 14, 2012 (permalink)

    Hi David,

    You only need to change the following line:
    column.set_filterFunction(filterFunction);

    to:
    column.set_filterFunction("Contains");

    and the filter function will get selected on inital filtering.

    Kind regards,
    Tsvetina
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Grid > Initial Grid filter expression on being passed to DataBinding
Related resources for "Initial Grid filter expression on being passed to DataBinding"

ASP.NET Grid Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]