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

Initial Grid filter expression on being passed to DataBinding

3 Answers 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 06 Feb 2012, 07:34 PM
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>

3 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 09 Feb 2012, 08:53 AM
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 >>
0
David
Top achievements
Rank 1
answered on 09 Feb 2012, 04:09 PM
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?
0
Tsvetina
Telerik team
answered on 14 Feb 2012, 01:33 PM
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 >>
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
David
Top achievements
Rank 1
Share this question
or