ComboBoxCellType in ColumnHeader doesn't display Filter icon

Posted by: roblander on 23 August 2023, 11:42 pm EST

    • Post Options:
    • Link

    Posted 23 August 2023, 11:42 pm EST - Updated 23 August 2023, 11:47 pm EST

    My spread has a column of boolean values which have been set as

    CellType = CheckBoxCellType
    . I have further added a checkbox to the column header which I use as a “check/uncheck-all”.

    Generally this works well however when I set the column to

    allowAutoFilter = true
    the icon for filtering doesn’t appear… The filter function however DOES work if you click the area where the icon should be (see attached screenshot).

    So, is this a bug or is there some configuration I have missed to get this working? I note that will other cell types having

    allowAutoFilter = true
    I do not have to take any additional steps to have the filter icon displayed…

  • Posted 24 August 2023, 8:42 pm EST

    Hi Robert,

    Thank you for explaining the problem so well.

    We could replicate this issue on our end. We have escalated this issue to the developers with the Internal Tracking ID: SPNET-32987.

    We will update you on this as soon as we hear back from them.

    Thanks & Regards,

    Aastha

  • Posted 5 September 2023, 5:16 am EST

    Hi Robert,

    When using the CheckBoxCellType cell as the header cell, it does not show the filter button due to its design behavior.

    However, you can override CheckBoxCellType’s PaintCell method to draw icon for filter button as shown in the following code:

    public class CheckBoxHeaderFilter : CheckBoxCellType
    {
        public override void PaintCell(System.Drawing.Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
        {
            base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
            int x = r.Right - 22;
            int y = r.Top + 6;
            GraphicsPath path = new GraphicsPath();
            path.AddLine(x + 4, y + 4, x + 12, y + 4);
            path.AddLine(x + 12, y + 4, x + 8, y + 8);
            path.AddLine(x + 8, y + 8, x + 4, y + 4);
            path.CloseFigure();
            using (SolidBrush brush = new SolidBrush(Color.Black))
            {
                g.FillPath(brush, path);
            }
        }
    }

    Kindly refer to the attached sample for full implementation. CheckboxHeaderFilter.zip

    Thanks & Regards,

    Aastha

  • Posted 26 September 2023, 12:14 am EST - Updated 26 September 2023, 12:20 am EST

    Dear support,

    Thank you for your response however the path you provided displays a sort icon (triangle) and not the filter icon (please see screen shots). Additionally, this path doesn’t match the other sort icons in your application.

    Can you kindly provide the correct path for the filter icon OR tell me where I can find it?

    In the attached screen shots the icon for the column “Use” clearly is a sort icon. The expected icon is right-most icon in the “Rigid Grains” column (it looks like a funnel). I also note that the sort icon you provided is solid back and slightly different than the default sort icon - again, see the sort icon in the Rigid Grains column.

    Thanks!

  • Posted 26 September 2023, 9:12 pm EST

    Hi Robert,

    You can use the following code-snippet to draw the funnel icon with white color fill in it:

    int x = r.Right - 22;
    int y = r.Top + 4;
    Point[] funnelPoints = new Point[]
    {
        new Point(x+2, y),
        new Point(x+9, y+7),
        new Point(x+9, y+13),
        new Point(x+13, y+13),
        new Point(x+13, y+7),
        new Point(x+20, y),
    };
    // Draw the funnel using a GraphicsPath
    GraphicsPath funnelPath = new GraphicsPath();
    funnelPath.AddPolygon(funnelPoints);
    g.FillPath(Brushes.WhiteSmoke, funnelPath);
    g.DrawPath(Pens.Black, funnelPath);
    

    Kindly refer to the attached sample for full implementation. (See CheckboxHeaderFilter_Mod.zip)

    Thanks & Regards,

    Aastha

  • Posted 27 September 2023, 1:45 am EST - Updated 27 September 2023, 1:50 am EST

    Dear support,

    Thank you again for providing an updated icon however this is not the same icon that is drawn by default in your component… Here’s the two in a side-by-side screen shot:

    As you can see the filter in the “Use” (checkbox column) that you provided does not match the icon in the “Rigid Grains” column…

    Please can you provide the path for the icon as it appears in the Rigid Grains column?

    Thanks!

  • Posted 27 September 2023, 5:28 pm EST

    Hi Rob,

    We are sorry to inform you that the exact path used for the default filter icon is not available for reference. However, we have tried to create the icon as close as possible to the default one. Please check the following code for the same:

    base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
    int x = r.Right - 22;
    int y = r.Top + (r.Height/2 - 9);
    Point[] funnelPoints = new Point[]
    {
        new Point(x+5, y),
        new Point(x+10, y+5),
        new Point(x+10, y+9),
        new Point(x+12, y+9),
        new Point(x+12, y+5),
        new Point(x+17, y),
    };
    // Draw the funnel using a GraphicsPath
    GraphicsPath funnelPath = new GraphicsPath();
    funnelPath.AddPolygon(funnelPoints);
    g.FillPath(Brushes.AntiqueWhite, funnelPath);
    g.DrawPath(new Pen(Brushes.SlateGray, 1.2f), funnelPath);
    GraphicsPath shadePath = new GraphicsPath();            
    shadePath.AddLine(new Point(x + 10, y+10), new Point(x + 12, y + 10));
    g.DrawPath(new Pen(Brushes.Black, 1.2f), shadePath);
    shadePath = new GraphicsPath();
    shadePath.AddLine(new Point(x + 10, y + 8), new Point(x + 12, y + 8));
    g.DrawPath(new Pen(Brushes.SlateGray, 1.4f), shadePath);
    shadePath = new GraphicsPath();
    shadePath.AddLine(new Point(x + 16, y + 1), new Point(x + 12, y + 5));
    g.DrawPath(new Pen(Brushes.SlateGray, 1.6f), shadePath);
    shadePath.AddLine(new Point(x + 17, y + 1), new Point(x + 13, y + 5));
    g.DrawPath(new Pen(Brushes.Black, 0.8f), shadePath);
    shadePath = new GraphicsPath();

    Kindly refer to the updated sample for the same. (See CheckboxHeaderFilter_Mod2.zip)

    Hope this helps!

    Thanks & Regards,

    Aastha

  • Posted 28 September 2023, 1:43 am EST

    This is much better thank-you!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels