Customize Sheet FilterBar

Posted by: develop on 23 September 2024, 7:54 am EST

    • Post Options:
    • Link

    Posted 23 September 2024, 7:54 am EST - Updated 23 September 2024, 7:59 am EST

    I want to customize the filter bar in a sheet.

    1. How can I hide the filter symbol and disable the context menu?
    2. How can I set the “Contains” filter directly in source-code?

  • Posted 24 September 2024, 11:30 pm EST

    Hi,

    1. You can hide the filter icon of the filter bar by defining the renderer for the FilterBarCellType as follows:

    FilterBarCellType filterBarCellType = new FilterBarCellType();
    filterBarCellType.ShowDropDownMenuStrip = false;
    filterBarCellType.SubEditor = null;
    fpSpread1.DefaultSkin.FilterBarDefaultStyle.Renderer = filterBarCellType;

    1. Could you please provide more details about your use case? Specifically, why is the filter bar essential in your scenario? Understanding your exact requirements will help us suggest a better approach that may be more suitable for your needs.

    Thanks & Regards,

    Aastha

  • Posted 8 January 2025, 6:24 am EST - Updated 8 January 2025, 6:29 am EST

    I want to have at top of the sheet one row as filter bar. The filter type is set as a “Contains” filter type.

    The user should not change the filter type. So no context menu is allow.

    Also the “Contains” text, “No filter” text and the filter icon should be hidden.

    And also the combobox should be as normal textbox.

    Overall: Just a filterbar the user can write a text and the rows will filtered with given text.

    Is there a way to customize or program a specific filter bar?

    Thank you.

  • Posted 9 January 2025, 8:25 am EST

    Hi,

    Thanks for the details.

    We are currently discussing this issue with our developers. [Internal Tracking ID: SPNET-45573]

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

    Thanks & Regards,

    Aastha

  • Posted 10 February 2025, 2:31 am EST

    Hi,

    For implementing the filter row with “Contains” filter condition only, you can consider settings the added row as “UnfilteredRow”, to make sure the row 0 is not filtered.

    private void Form1_Load(object sender, EventArgs e)
      {
      ..............
      //settings add UnfilteredRows to make sure the row 0 are not be filltered
        rowFilter.UnfilteredRows = new int[] { 0 };
      }
    

    Further, you can update the EditChange event as shown in the following code snippet:

    private void FpSpread1_EditChange(object sender, EditorNotifyEventArgs e)
    {
        if (e.Row == 0)
        {
            Debug.WriteLine("Called...");
            for (int i = 0; i < fpSpread1.ActiveSheet.ColumnCount; i++)
            {
                string text = fpSpread1.ActiveSheet.Cells[0, i].Text;
                if (text != String.Empty)
                {
                    FilterCondition fcd = new FilterCondition(CustomFilterOperatorType.Equal, "*" + text + "*");
                    CustomFilterItem activeFilter = new CustomFilterItem(fcd, null, true);
                    activeFilter.SheetView = fpSpread1.ActiveSheet;
                    FilterColumnDefinition filterColumnDefinition = new FilterColumnDefinition(i, FilterListBehavior.Custom);
                    filterColumnDefinition.Filters.Add(activeFilter);
                    rowFilter.ColumnDefinitions.Add(filterColumnDefinition);
                    fpSpread1.ActiveSheet.AutoFilterColumn(i, activeFilter.DisplayName, 0);
                }
                else
                {
                    fpSpread1.ActiveSheet.AutoFilterColumn(i, null, 0);
                }
            }
        }
    }

    Kindly refer to the attached sample for full implementation. [FilterModify_mod.zip]

    Thanks & regards,

    Aastha

Need extra support?

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

Learn More

Forum Channels