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

Grid Filter Box Item Style

2 Answers 29 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve Todd
Top achievements
Rank 1
Steve Todd asked on 02 Oct 2009, 02:43 PM
Hi There

Is there a way to colour the background e.g. white text on red background, of the filter box (on the grid header) when it has a value in it, non-completed filter boxes to remain white.

Regards

Steve

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 05 Oct 2009, 11:56 AM
Hi Steve,

I guess you want to change the style when losing the focus of filter textbox. If so try out the following approach and see whether it works.

C#:
 
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    if( e.Item is GridFilteringItem ) 
    { 
        GridFilteringItem filterItem = (GridFilteringItem)e.Item; 
        TextBox textBox = (TextBox) filterItem["CustomerID"].Controls[0]; 
        textBox.Attributes.Add("onfocusout","changeStyle('"+textBox.ClientID+"')"); 
    } 

JavaScript:
 
<script type="text/javascript"
    function changeStyle(textbox) { 
        var text = document.getElementById(textbox); 
        if (text.value == '') { 
            text.style.color = 'black'
            text.style.backgroundColor = 'white';           
        } 
        else { 
            text.style.color = 'white'
            text.style.backgroundColor = 'red'
        } 
    } 
</script> 

-Shinu.
0
Steve Todd
Top achievements
Rank 1
answered on 05 Oct 2009, 02:05 PM
Hi Shinu

That is spot on. Thank you very much

Regards

Steve
Tags
Grid
Asked by
Steve Todd
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Steve Todd
Top achievements
Rank 1
Share this question
or