Hi,
I've recently added functionality to one of my radgrids so that a Filter will be applied when the user presses Enter in the Filter text box.
I have the CurrentFilterFunction set to "Contatins" on most columns and set the AutoPostbackOnFilter property to True.
I've also kept the Filter menu so that the user can choose another filter option.
One issue I've noticed is that if the user types in the the filter text box and then clicks on the menu to select another option, the default filter is immediately applied, which is a little annoying as then the grid has to apply the filter option chosen in the menu.
I've tried a few different ways to prevent this from happening without full success. One workaround was to set the AutoPostbackOnFilter property to false and then set the FilterDelay to a high value. This works on all columns except datetime columns.
Is there a way to cancel the default Filter when the user clicks on the menu but also allow the user to press enter to apply the filter? I have noticed that on all of the demos of this functionality on this site, the Filter menu is removed from columns that have AutoPostBackOnFilter set to True. Is there an issue with using both together?
Thanks.
I've recently added functionality to one of my radgrids so that a Filter will be applied when the user presses Enter in the Filter text box.
I have the CurrentFilterFunction set to "Contatins" on most columns and set the AutoPostbackOnFilter property to True.
I've also kept the Filter menu so that the user can choose another filter option.
One issue I've noticed is that if the user types in the the filter text box and then clicks on the menu to select another option, the default filter is immediately applied, which is a little annoying as then the grid has to apply the filter option chosen in the menu.
I've tried a few different ways to prevent this from happening without full success. One workaround was to set the AutoPostbackOnFilter property to false and then set the FilterDelay to a high value. This works on all columns except datetime columns.
<
MasterTableView
DataSourceID
=
"ProjectsDS"
ClientDataKeyNames
=
"ID"
>
<
Columns
>
<
telerik:GridClientSelectColumn
UniqueName
=
"projectsSelect"
Visible
=
"false"
/>
<
telerik:GridBoundColumn
Visible
=
"True"
DataField
=
"ID"
UniqueName
=
"ID"
HeaderText
=
"ID"
AutoPostBackOnFilter
=
"False"
CurrentFilterFunction
=
"EqualTo"
FilterDelay
=
"60000"
/>
<
telerik:GridBoundColumn
DataField
=
"Name"
HeaderText
=
"Name"
UniqueName
=
"Name"
AutoPostBackOnFilter
=
"False"
CurrentFilterFunction
=
"Contains"
FilterDelay
=
"60000"
/>
<
telerik:GridBoundColumn
DataField
=
"CampaignName"
HeaderText
=
"Campaign"
UniqueName
=
"CampaignName"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"FilterCombo"
runat
=
"server"
AutoPostBack
=
"false"
AppendDataBoundItems
=
"true"
DataSourceID
=
"CampaignDS"
DataTextField
=
"Name"
DataValueField
=
"ID"
OnClientSelectedIndexChanged
=
"SelectedIndexChanged"
SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("CampaignID").CurrentFilterValue %>'>
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"No filters."
Value
=
""
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function SelectedIndexChanged(sender, args) {
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
tableView.filter("CampaignID", args.get_item().get_value(), "EqualTo");
}
function clientItemClicking(sender, args) {
if (args.get_item().get_value() === "NoFilter") {
var target = args.get_targetElement();
var filterBox = target.parentNode.getElementsByTagName("input")[0];
filterBox.value = "";
}
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CampaignID"
HeaderText
=
"CampaignID"
UniqueName
=
"CampaignID"
Display
=
"false"
/>
<
telerik:GridBoundColumn
DataField
=
"FrameworkName"
HeaderText
=
"Framework"
UniqueName
=
"FrameworkName"
AutoPostBackOnFilter
=
"False"
CurrentFilterFunction
=
"Contains"
FilterDelay
=
"60000"
/>
<
telerik:GridBoundColumn
DataField
=
"ProjectBaseName"
HeaderText
=
"Template"
UniqueName
=
"ProjectBaseName"
AutoPostBackOnFilter
=
"False"
CurrentFilterFunction
=
"Contains"
FilterDelay
=
"60000"
/>
<
telerik:GridBoundColumn
DataField
=
"StatusDisplayValue"
HeaderText
=
"Status"
UniqueName
=
"StatusDisplayValue"
AutoPostBackOnFilter
=
"False"
CurrentFilterFunction
=
"Contains"
FilterDelay
=
"60000"
/>
<
telerik:GridDateTimeColumn
DataField
=
"StartDate"
HeaderText
=
"Start Date"
UniqueName
=
"StartDate"
DataFormatString
=
"{0:d}"
AutoPostBackOnFilter
=
"True"
CurrentFilterFunction
=
"EqualTo"
FilterDelay
=
"60000"
>
</
telerik:GridDateTimeColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"EndDate"
HeaderText
=
"End Date"
UniqueName
=
"EndDate"
DataFormatString
=
"{0:d}"
AutoPostBackOnFilter
=
"True"
CurrentFilterFunction
=
"EqualTo"
>
</
telerik:GridDateTimeColumn
>
<
telerik:GridBoundColumn
DataField
=
"ExternalID"
HeaderText
=
"External ID"
UniqueName
=
"ExternalID"
AutoPostBackOnFilter
=
"False"
CurrentFilterFunction
=
"Contains"
FilterDelay
=
"60000"
/>
<
telerik:GridTemplateColumn
DataField
=
"IsArchived"
HeaderText
=
"Archived"
UniqueName
=
"IsArchived"
Visible
=
"false"
GroupByExpression
=
"IsArchived Group By IsArchived"
>
<
HeaderTemplate
>
<
asp:CheckBox
ID
=
"chkArchivedSelectAll"
OnCheckedChanged
=
"chkArchivedSelectAll_CheckedChanged"
AutoPostBack
=
"true"
runat
=
"server"
TextAlign
=
"Right"
Text
=
" Archived"
/>
</
HeaderTemplate
>
<
ItemTemplate
>
<
asp:CheckBox
ID
=
"IsArchived"
Checked='<%# Bind("IsArchived") %>' runat="server" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
Is there a way to cancel the default Filter when the user clicks on the menu but also allow the user to press enter to apply the filter? I have noticed that on all of the demos of this functionality on this site, the Filter menu is removed from columns that have AutoPostBackOnFilter set to True. Is there an issue with using both together?
Thanks.