My Grid has a RadTextBox that is being used to filter on all the columns. It Looks like this:
Now when I click the button to do the filtering, this function gets called.
This works as expected. But after the Rebind(), the filtering becomes active, which clears the text in my textbox. I don't want it to be cleared, so you can still see what your filter searches for. Is it somehow possible to keep the text in the textbox?
<
telerik:RadGrid
runat
=
"server"
ID
=
"grid1"
GridLines
=
"None"
ShowFooter
=
"False"
Culture
=
"de-DE"
>
<
MasterTableView
AutoGenerateColumns
=
"False"
AllowMultiColumnSorting
=
"True"
CommandItemDisplay
=
"Top"
>
<
CommandItemTemplate
>
<
telerik:RadToolBar
ID
=
"radToolBar"
Skin
=
"Windows7"
runat
=
"server"
AutoPostBack
=
"true"
Width
=
"100%"
>
<
Items
>
<
telerik:RadToolBarButton
Value
=
"section2"
>
<
ItemTemplate
>
<
telerik:RadTextBox
ID
=
"textbox1"
runat
=
"server"
Skin
=
"Windows7"
><
ClientEvents
OnKeyPress
=
"OnKeyPress"
/></
telerik:RadTextBox
>
<
telerik:RadButton
ID
=
"btnSearch"
runat
=
"server"
Skin
=
"Windows7"
Text
=
"Search"
CommandName
=
"Search"
OnClick
=
"searchButton_Click"
/>
</
ItemTemplate
>
</
telerik:RadToolBarButton
>
</
Items
>
</
telerik:RadToolBar
>
</
CommandItemTemplate
>
</
MasterTableView
>
<
GroupingSettings
CaseSensitive
=
"False"
/>
</
telerik:RadGrid
>
Now when I click the button to do the filtering, this function gets called.
protected
void
searchButton_Click(
object
sender, EventArgs e)
{
RadTextBox searchFilter = GetSearchBox();
if
(searchFilter ==
null
)
return
;
var filterExpression =
new
StringBuilder();
var searchText = searchFilter.Text;
foreach
(GridColumn col
in
grid1.MasterTableView.Columns)
{
filterExpression.AppendFormat(
"{0}(it[\"{1}\"].ToString().ToUpper().Contains(\"{2}\".ToUpper()))"
,
filterExpression.Length != 0 ?
" OR "
:
string
.Empty, col.UniqueName, searchText);
}
activePassiveGrid.MasterTableView.FilterExpression = filterExpression.ToString();
activePassiveGrid.MasterTableView.Rebind();
}
This works as expected. But after the Rebind(), the filtering becomes active, which clears the text in my textbox. I don't want it to be cleared, so you can still see what your filter searches for. Is it somehow possible to keep the text in the textbox?