In radgrid i want the default criteria for filter to be "contains" on enter key press. Like if i give the filter criteria in names column as "s" and press enter key then it should show the result rather opening the filter menu and selecting "contains" from the menu.
19 Answers, 1 is accepted
If you set AutoPostBackOnFilter property of the corresponding column to true you can trigger postback filter operation for Contains (for string types) and EqualTo (for numeric types) when you type in the filter box and press [Enter] from the keyboard. Moreover, you can execute other type of filter action by setting the CurrentFilterFunction property of the corresponding column to an internally recognized value.
Greetings,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thanks for your reply. I have tried what you have asked for but its not working for [Enter] its doing that action on [Tab] key press.
The below is my grid structure, see if i am missing something in it.
<
telerik:RadGrid ID="grdList" runat="server" AutoGenerateColumns="False" AllowFilteringByColumn="True"
AllowSorting="True" AllowPaging="True" PageSize="5" OnNeedDataSource="grdList_NeedDataSource"
Skin="Default" PagerStyle-AlwaysVisible="true" OnItemCreated="grdList_ItemCreated"
EnableEmbeddedSkins="False" OnItemCommand="grdList_ItemCommand" meta:resourcekey="grdListResource1"
OnPreRender="grdList_PreRender" OnPageIndexChanged="grdList_PageIndexChanged"
EnableLinqExpressions="False" GridLines="None">
<GroupingSettings CaseSensitive="false" />
<HeaderContextMenu Skin="Default" EnableEmbeddedSkins="False" EnableTheming="True">
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
</HeaderContextMenu>
<PagerStyle AlwaysVisible="True"></PagerStyle>
<MasterTableView CommandItemDisplay="None" AutoGenerateColumns="False" Width="100%"
AllowFilteringByColumn="true">
<EditFormSettings>
<EditColumn InsertImageUrl="Update.gif" UpdateImageUrl="Update.gif" EditImageUrl="Edit.gif"
CancelImageUrl="Cancel.gif">
</EditColumn>
</EditFormSettings>
<PagerStyle Mode="Slider" />
<CommandItemSettings AddNewRecordImageUrl="AddRecord.gif" RefreshImageUrl="Refresh.gif">
</CommandItemSettings>
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="UserGroupId" HeaderText="ID" ReadOnly="True"
SortExpression="UserGroupId" UniqueName="UserGroupId" Visible="false" CurrentFilterFunction="Contains"
meta:resourcekey="GridBoundColumnResource2">
</telerik:GridBoundColumn>
<telerik:GridHyperLinkColumn HeaderText="User Groups" AutoPostBackOnFilter="true" DataTextField="Name" DataType="System.String"
DataNavigateUrlFields="UserGroupId" DataNavigateUrlFormatString="UserGroupEdit.aspx?Id={0}"
UniqueName="Name" SortExpression="Name" CurrentFilterFunction="Contains" FilterListOptions="VaryByDataType"
meta:resourcekey="GridHyperLinkColumnResource3">
</telerik:GridHyperLinkColumn>
<telerik:GridHyperLinkColumn HeaderText="Copy User Group" DataType="System.String" DataNavigateUrlFields="UserGroupId"
DataNavigateUrlFormatString="UserGroupEdit.aspx?CopyId={0}" UniqueName="Copy"
AllowFiltering="false" Text="Copy/Add" meta:resourcekey="GridHyperLinkColumnResource4">
</telerik:GridHyperLinkColumn>
<telerik:GridTemplateColumn HeaderText="Active" UniqueName="IsActive" HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Center" SortExpression="IsActive" DataField="IsActive"
Resizable="false" ItemStyle-Width="20%" meta:resourcekey="GridTemplateColumnResource2">
<ItemTemplate>
<asp:CheckBox ID="chkActive" runat="server" AutoPostBack="True" Checked='<%# Bind("IsActive") %>'
OnCheckedChanged="chkActive_CheckedChanged" meta:resourcekey="chkActiveResource2" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="20%"></ItemStyle>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True" AllowKeyboardNavigation="true">
<Resizing AllowColumnResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="True" />
<ClientEvents OnColumnContextMenu="ColumnContextMenu" />
</ClientSettings>
<FilterMenu Skin="Default" EnableEmbeddedSkins="False" EnableTheming="True">
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
</FilterMenu>
</telerik:RadGrid>
Thanks
Sandeep
Even this works for the first time i mention the filter criteria, second time i have to refresh the page for the criteria to work on key press again.
I suggest you upgrade to latest version and see if the same behaviour can be observed.
I belive this is fixed in Q1 Release of RadControls for ASP.NET AJAX.
All the best,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Could you please give me the link for the Latest version, i am not able to figure it out where exactly i can find it.
Thanks
Sandeep
Here is a KB article which explains how to upgrade Radcontrols from one version to another.
Updating RadControls for ASP.NET to another version or license
You may refer the following link where you can buy the individual product.
Purchase Individual Product
You can also download the trial version from here.
Free Trials
Thanks
Shinu
The new issue which i am facing with this is, if i enter something in filter criteria and click(mouse click) on filter icons for Filter menu it first filters and then i need to click again for filter options.
This should not happen as the default filtering is on enter key and not on mouse click.
Do i need to add something for default filtering on just enter key and not on any other key press?
You can either enable filtering on Enter key press or disable it and use the filtering menu options as demonstrated on this online demo of the product:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/filtering/defaultcs.aspx
The filtering operation is triggered on blur of the filter control, hence you will need to choice either the first or the second option depending on your particular needs.
Best regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I don't want the event to trigger on OnBlur, i want it on enter key press.
Please suggest any workaround for it, otherwise this functionality is of no use.
Thanks,
Sandeep
I am in urgent need for this functionality, please provide me with some workaround.
I want this functionality on key press rather than onBlur.
If you would like to implement filtering on Enter key press, you will need to hide the filtering icon and perform filter operation in this way as it will be triggered on blur. Unfortunately there is no universal mechanism to trigger the action on Enter key press only, hence if you would like to enable both options at the same time, you will need to do that with your custom implementation.
A possible alternative approach is presented on this demo of the product:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/webmailgrid/defaultcs.aspx
Best regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Can you provide some sample on custom implementation?
The alternative solution is not what i need. So please can you provide some sample on custom implementation
One possible custom implementation is provided in the demo linked in my previous post. If you find another solution, feel free to implement it and post it in this public forum thread to be available for other community members as well. Your effort will be rewarded with Telerik points that can be used as a discount for future upgrades/purchases of our controls.
Kind regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Hi,
Thanks for your reply. Can we disable onblur event and fire filtering event through javascript.
What I want to do is, when user presses Enter key I want to call filtering event using javascript.
Onfocus event of filter textbox I should be able to store that filter textbox id in hidden field and on press of enter key
I can get value in filter text box and fire filtering event using javascript.
Is it making sense?
You may consider implementing your custom solution intercepting the onblur event of the filter textboxes manually inside the ItemCreated handler and the OnKeyPress client event of the grid to determine when [Enter] key is pressed.
To trigger filtering operation from the client, you can use the filter method of the grid as demonstrated on this demo.
Best regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Please excuse me if my previous directions were a bit misleading for you. Actually you need to cancel the onchange event for the filter textboxes for columns with AutoPostBackOnFilter = true setting and do not need to intercept the OnKeyPress event of the grid at all.
For your convenience I prepared a test project which illustrates how this can be done for the OrderID and ShipName columns in the grid. Let me know whether this helps.
Best regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thanx,
Manuel
| Protected Sub rgMasterGrid_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgMasterGrid.ItemCreated |
| If TypeOf e.Item Is GridFilteringItem Then |
| Dim filterItem As GridFilteringItem = CType(e.Item, GridFilteringItem) |
| For Each filtercell As TableCell In filterItem.Cells |
| For Each cellcontrol As Object In filtercell.Controls |
| If TypeOf cellcontrol Is TextBox Then |
| CType(cellcontrol, TextBox).Attributes("onchange") = "" |
| End If |
| Next |
| Next |
| End If |
| End Sub |
Thank you for your feedback. I will forward your proposal to our developers to be considered further.
However, I am afraid that such modification will introduce a breaking change in RadGrid for ASP.NET AJAX which will affect all existing clients when migrating to a newer version of the product. Our goal is to avoid breaking changes unless they are absolutely necessary. That is why you may consider configuring the filter on [ENTER] key press manually - I hope this is feasible solution for you.
Kind regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.