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

EmptyMessage for Filter textbox

1 Answer 136 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Farshad heidary
Top achievements
Rank 1
Farshad heidary asked on 30 Apr 2010, 06:46 AM
hi guys

how i can set empty message to Filter?
my column is Template column

tnx

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 30 Apr 2010, 11:35 AM
Hi,

You could access the textbox in the FiteringItem and set the watermark for the textbox by using custom logic. Attach onfocus/onblur events for textbox control and set the Text property accordingly, in order to achieve the desired functionality. Try the code in ItemDataBound event of RadGrid. Here is the code example that I tried.

cs:
      
        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
            if (e.Item is GridFilteringItem) 
            { 
                GridFilteringItem filerItem = (GridFilteringItem)e.Item; 
                TextBox textItem = (TextBox)filerItem["TempColumn"].Controls[0]; 
                textItem.Text = "Type the filter"
                textItem.Attributes.Add("onBlur", "return SetMessage(" + textItem.ClientID + ");"); 
                textItem.Attributes.Add("onFocus", "return ClearMessage(" + textItem.ClientID + ");"); 
            } 
        } 

aspx:
 
             <MasterTableView>           
                <Columns> 
                    <telerik:GridTemplateColumn UniqueName="TempColumn">         
                        <ItemTemplate>  
                         ............... 
                        </ItemTemplate> 
                      </telerik:GridTemplateColumn> 
                     ............... 
                 </Columns>  
               </MasterTableView>  
 

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

Regards,
Princy.
Tags
Grid
Asked by
Farshad heidary
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or