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. Image for the cookie policy date
close icon

Filter empty rows

Hello,

I am using a griddataboudgrid (5.2) in a windows form application. In some columns, rows are empty. I want to filter rows that are empty. Is it possible to have the empty value in the filter list as anyother value?


1 Reply

JS Jeba S Syncfusion Team February 9, 2008 07:42 AM UTC

Hi Vincent,

Sorry for the delay in response.

You can achieve this by deriving the GridFilterBar class.In the derived class override the GridFilterBarRow and CreateUnquieEnteries methods to add the "[Empty]"option in a FilterBar. Below is the code snippets:


public class MyGridFilterBar : GridFilterBar
{
private GridDataBoundGrid grid1;
public override void WireGrid(GridDataBoundGrid grid, GridStyleInfo style)
{this.grid1 = grid;
base.WireGrid (grid, style);
}
protected override string GetFilterFromRow(GridDataBoundGrid grid)
{GridCurrentCell cc = grid.CurrentCell;
string s = cc.Renderer.ControlText;
string rowFilter = base.GetFilterFromRow(grid);
if(s != "[Empty]")
return rowFilter;
else
return rowFilter.Replace("[Empty]","") ;
}
protected override DataTable CreateUniqueEntries(DataView dv, string colName)
{DataTable dtt = base.CreateUniqueEntries(dv,colName);
DataRow dr= dtt.NewRow();
dr[0]="[Empty]";
dtt.Rows.InsertAt(dr,2);
return dtt;
}
}


Please refer the below sample and let us know if this helps:
http://websamples.syncfusion.com/samples/Grid.Windows/I71516/main.htm

Regards,
Jeba.


Loader.
Live Chat Icon For mobile
Up arrow icon