Overwrite method items in combox

Posted by: cangod05 on 16 January 2023, 5:19 am EST

  • Posted 16 January 2023, 5:19 am EST

    Hi admin,

    I have an issue when i customize a cell by extending cell combobox type. i want to filter item in the class but when i call super when overwrite I always get class instead items. Do you have any solution for this problem.

    Tks you sir.

  • Posted 20 January 2023, 2:29 am EST

    Hi,

    Please accept my apologies for the delayed response.

    According to my understanding, you are extending the ComboBox Cell Type and want to overwrite the items method to implement some sort of filtering on the items.

    If this is the case, you could use the code snippet below:

        // Custom Cell Type
        function CustomCellType() { }
        CustomCellType.prototype = new GC.Spread.Sheets.CellTypes.ComboBox;
    
        // Ovewrite the items method
        CustomCellType.prototype.items = function (items) {
            // Implement your own custom filter here
            let filteredItems = items.filter((item) => {
                return !item.text.startsWith("O");
            })
            return GC.Spread.Sheets.CellTypes.ComboBox.prototype.items.apply(this, [filteredItems]);
        }

    Sample: https://jscodemine.grapecity.com/share/NSr14GHq9EWABJ7irrRoqw/?defaultOpen={"OpenedFileName"%3A["%2Fsrc%2Fapp.js"]%2C"ActiveFile"%3A"%2Fsrc%2Fapp.js"}

    ComboBox items method: https://www.grapecity.com/spreadjs/api/classes/GC.Spread.Sheets.CellTypes.ComboBox#items

    Please let us know if you have a different use case. We’d be delighted to assist you.

    Regards,

    Ankit

Need extra support?

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

Learn More

Forum Channels