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

Filtering in Radgird

1 Answer 22 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Janaki
Top achievements
Rank 1
Janaki asked on 14 Jun 2012, 10:50 AM
Hi all,

I have set filtering in my radgrid using 'Allow Filtering By column'. I have made the filter button invisible and set autopostbackonfilter on each column want to give the user an idea about what to be given in the textbox, by giving a text like 'Enter name to filter'. How can I  accomplish this?

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 14 Jun 2012, 11:04 AM
Hi Janaki,

Please try the following code snippet to show a message in the filtering Textbox.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridFilteringItem)
    {
        GridFilteringItem fitem = (GridFilteringItem)e.Item;
        TextBox textbox = (TextBox)fitem["UniqueName"].Controls[0];
        textbox.Text = "Enter the name to filter";
        textbox.Attributes.Add("onBlur", "return SetMessage(" + textbox.ClientID + ");");
        textbox.Attributes.Add("onFocus", "return ClearMessage(" + textbox.ClientID + ");");
    }
}

Javascript:
<script type="text/javascript">
    function ClearMessage(obj)
    {
         if (obj.value == "Enter the name to filter")
         {
 
             obj.value = "";
         }
    }
    function SetMessage(obj)
    {
        if (obj.value == "")
        {
 
            obj.value = "";
        }
    }
</script>

Thanks,
Princy.
Tags
Grid
Asked by
Janaki
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or