We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Is it possible to add a placeholder in the filter cell?

Thread ID:

Created:

Updated:

Platform:

Replies:

131975 Aug 6,2017 06:29 PM Feb 13,2018 08:15 AM WPF 3
loading
Tags: GridDataControl
Carlos Fernando Consigli
Asked On August 6, 2017 06:29 PM

I'm using a GridDataControl with FilterBarMode=Immediate. Is it possible to add a "Placehoder" like "Type to filter" or "Type to search" in the filter cell? It would be a grey text that disappears as soon as you start typing there.
I haven't found it in the documentation but I may be searching it wrongly.
Thanks in advance

Balamurugan Rajaraman [Syncfusion]
Replied On August 8, 2017 07:58 AM

Hi Carlos 
 
Thanks for contacting Syncfusion support. 
 
We have checked your query “To add a placeholder in the filter cell”. You can able to achieve your requirement by customizing the OnRender method of the GridDataFilterBarCellRenderer as like the below provide code sample. 
 
 
this.dataGrid.Model.CellModels.Remove("FilterBarCell"); 
this.dataGrid.Model.CellModels.Add("FilterBarCell", new GridFilterBarCellModelExt()); 
 
. . .  
 
public class GridFilterBarCellModelExt : GridCellModel<GridCellTextBoxRendererExt> 
{ 
 
} 
 
public class GridCellTextBoxRendererExt: GridDataFilterBarCellRenderer 
{ 
public GridCellTextBoxRendererExt():base() 
{ 
 
} 
       
protected override void OnRender(DrawingContext dc, RenderCellArgs rca, GridRenderStyleInfo style) 
{ 
    if (rca.CellUIElements != null) 
        return; 
    var margins = style.TextMargins.ToThickness(); 
    if (style.HasImageIndex) 
    { 
        margins = style.AdjustImageWidthAndHeightToMargin(margins, rca.CellRect.Size); 
    } 
    else 
    { 
        margins = style.ErrorInfo.AdjustErrorInfoMargin(margins, rca.CellRect.Size); 
    } 
    Rect textRectangle = rca.SubtractBorderMargins(rca.CellRect, margins); 
    if (textRectangle.IsEmpty) 
        return; 
 
    margins.Left = Math.Max(margins.Left, 2); 
    margins.Right = Math.Max(margins.Right, 2); 
    string text = GetControlText(style); 
    if (text == string.Empty) 
        text = "Type to filter"; 
    GridTextBoxPaint.DrawText(dc, textRectangle, text, style); 
} 
      
} 
 
In this sample we have applied the custom test in the OnRender to display that text as like the placeholder text. We have attached the sample for your reference you can able to get it from below link 
 
 
Regards, 
Balamurugan R 


Carlos Fernando Consigli
Replied On February 12, 2018 06:15 PM

I'm really REALLY sorry about my lack of feedback on this. It was a minor request and it was postponed and almost forgotten.
It worked perfectly, thanks a lot for your help.

Muthukumar Kalyanasundaram [Syncfusion]
Replied On February 13, 2018 08:15 AM

Hi Carlos, 
 
You are welcome. Please let us know if you need further assistance. 
 
Regards, 
Muthukumar K 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;