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

How to enable ExcelStyleFIlter only for specific columns

In your ExcelStyleFilter, the filter is enable for every column header cell.

How can I enable the filter just for specific cells?

How can I remove the 'Empty' and 'Custom' options from the drop down?

Can I replace the dialog the pops up when custom is selected with my own?

1 Reply

AD Administrator Syncfusion Team December 5, 2006 06:20 AM UTC

Hi James,

1) How can I enable the filter just for specific cells?

Instead of removing the ColumnHeader cellmodel from the grid in the form's load, you can add the extra cell model called "ExcelColumnHeader" for filter column header of the grid. Here is a code snippet to show the ExcelColumnHeader for first column.

this.gridGroupingControl1.TableModel.CellModels.Add("ExcelColumnHeaderCell", new GridSortHeaderCellModel(this.gridGroupingControl1.TableModel));

this.gridGroupingControl1.TableDescriptor.Columns[1].Appearance.ColumnHeaderCell.CellType = "ExcelColumnHeaderCell";

2) How can I remove the 'Empty' and 'Custom' options from the drop down?

In the GridSortHeaderCellRenderer class, you can comment these line to remove the custom and empty options from the filter in the Grid_CellClick eventHandler. Here is a code snippet

private void Grid_CellClick(object sender, GridCellClickEventArgs e)
{
list.Hide();
if( filterRect.IntersectsWith(new Rectangle(e.MouseEventArgs.X,e.MouseEventArgs.Y,0,0)))
{
list.DataSource = null;
GridTableControl grid = this.Grid as GridTableControl;

list.Items.Clear();

DataTable dt = grid.Table.Engine.DataSource as DataTable;
CurrentColumnName = grid.TableDescriptor.Columns[ e.ColIndex - 1].MappingName;
list.Items.Add("All");
///////list.Items.Add("Custom");
///////list.Items.Add("Empty");

foreach( DataRow row in dt.Rows)
{
list.Items.Add(row[e.ColIndex -1]);
}
////your code here.
}
}

3)Can I replace the dialog the pops up when custom is selected with my own?

Yes. You can handle the List.Click event in GridSortHeaderCellRenderer and check the "Custom" to display your own pop.

else if ( row.ToString() == "Custom")
{
//You own pop here.
}

Please refer the sample for implementation.
ExcelStyleFilter_2003.zip

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon