I need to have a text box in my GridHyperLinkColumn inside a radgrid that says "search here" on page load but when a user clicks on the box to search, I want to test to disappear. How can I do that. Currently I am using a filter control to display search here but it doesn't disappear when I click on it.
Thanks,
Thanks,
5 Answers, 1 is accepted
0
Accepted

Shinu
Top achievements
Rank 2
answered on 09 May 2014, 09:32 AM
Hi Mehreen,
Please try the following code snippet to show a TextBox in GridHyperColumn and add a EmptyMessage in that TextBox.
ASPX:
C#:
Thanks,
Shinu.
Please try the following code snippet to show a TextBox in GridHyperColumn and add a EmptyMessage in that TextBox.
ASPX:
<
telerik:RadGrid
ID
=
"radgrdOrders"
runat
=
"server"
DataSourceID
=
"SqlDataSource1"
AutoGenerateColumns
=
"false"
OnItemCreated
=
"radgrdOrders_ItemCreated"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridHyperLinkColumn
DataTextField
=
"OrderID"
UniqueName
=
"OrderID"
NavigateUrl
=
"#"
>
</
telerik:GridHyperLinkColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
C#:
protected
void
radgrdOrders_ItemCreated(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem dataItem = (GridDataItem)e.Item;
TableCell cell = (TableCell)dataItem[
"OrderID"
];
RadTextBox searchText=
new
RadTextBox();
searchText.ID=
"radtxtSearch"
;
searchText.EmptyMessage=
"Search here"
;
cell.Controls.Add(searchText);
}
}
Thanks,
Shinu.
0

Mehreen
Top achievements
Rank 1
answered on 09 May 2014, 03:31 PM
Hi Shinu,
When I put in this code, its inserting a text box in every field of the GridHyperLinkColumn and its still not performing a search. its not doing anything. I only want the search box to appear in the header of the column and when a user puts in a term, I need it to search the column for that term and display results.
When I put in this code, its inserting a text box in every field of the GridHyperLinkColumn and its still not performing a search. its not doing anything. I only want the search box to appear in the header of the column and when a user puts in a term, I need it to search the column for that term and display results.
0
Accepted

Shinu
Top achievements
Rank 2
answered on 12 May 2014, 06:34 AM
Hi Mehreen,
Please try the following sample code snippet to achieve your scenario.
ASPX:
Thanks,
Shinu.
Please try the following sample code snippet to achieve your scenario.
ASPX:
<
telerik:RadGrid
ID
=
"radgrdOrders"
runat
=
"server"
AllowFilteringByColumn
=
"true"
DataSourceID
=
"SqlDataSource1"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridHyperLinkColumn
DataTextField
=
"OrderID"
UniqueName
=
"OrderID"
NavigateUrl
=
"#"
>
<
FilterTemplate
>
<
telerik:RadSearchBox
ID
=
"RadSearchBox1"
runat
=
"server"
EmptyMessage
=
"search"
DataSourceID
=
"SqlDataSource1"
DataTextField
=
"CustomerID"
OnClientSearch
=
"OnClientSearch"
>
</
telerik:RadSearchBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function OnClientSearch(sender, args) {
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
tableView.filter("CustomerID", args.get_text(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridHyperLinkColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Thanks,
Shinu.
0

Mehreen
Top achievements
Rank 1
answered on 13 May 2014, 06:16 AM
I used this code but without the sqldatasource since I am using sql query in linq to get the data. And now this code does not do the search since it does not have a data source. What is the alternative method of performing the search in this case?
Thanks
Thanks
0

Shinu
Top achievements
Rank 2
answered on 13 May 2014, 07:33 AM
Hi Mehreen,
You can use a RadTextBox in the FilterTemplate and on its TextChanged event you can search for the text and filter the grid to show values related to that search. Please take a look at the following:
set EnableLinqExpressions="false"
ASPX:
C#:
Thanks,
Shinu
You can use a RadTextBox in the FilterTemplate and on its TextChanged event you can search for the text and filter the grid to show values related to that search. Please take a look at the following:
set EnableLinqExpressions="false"
ASPX:
<
telerik:GridHyperLinkColumn
DataTextField
=
"CustomerID"
UniqueName
=
"CustomerID"
NavigateUrl
=
"#"
>
<
FilterTemplate
>
<
telerik:RadTextBox
ID
=
"radtxtSearch"
runat
=
"server"
EmptyMessage
=
"Search Here"
AutoPostBack
=
"true"
OnTextChanged
=
"radtxtSearch_TextChanged"
>
</
telerik:RadTextBox
>
</
FilterTemplate
>
</
telerik:GridHyperLinkColumn
>
C#:
protected
void
radtxtSearch_TextChanged(
object
sender, EventArgs e)
{
RadTextBox txtSearch = (RadTextBox)sender;
RadGrid1.MasterTableView.FilterExpression =
"(CustomerID ='"
+ txtSearch.Text +
"')"
;
GridColumn column = RadGrid1.MasterTableView.GetColumnSafe(
"CustomerID"
);
column.CurrentFilterFunction = GridKnownFunction.EqualTo;
column.CurrentFilterValue = txtSearch.Text;
RadGrid1.Rebind();
}
Thanks,
Shinu