0

I am trying to use this spreadsheet control.

I want to Add new row with same drop down values in Spreadsheet

 var sheet = [ {
            ranges: [{ dataSource: tradeData }],
            fieldAsColumnHeader: true,
            columns: [

                { width: 70 }, { width: 80 }, { width: 100 }, { width: 100 },

                { width: 70 }, { width: 120 }, { width: 80 }, { width: 120 },

                { width: 140 }, { width: 80 }, { width: 120 }, { width: 120 }

            ],

            rows: [
                {
                    index: 1,
                    cells: [

                        { index: 3, value: '', validation: { type: 'List', value1: trade_types.toString() } },

                        { index: 5, value: '', validation: { type: 'List', value1: securities.toString() } },

                        { index: 11, value: '', validation: { type: 'List', value1: reason_for_trades.toString() } }]

                }
            ]
        }
    ];

    var spreadsheet = new ej.spreadsheet.Spreadsheet({
        showRibbon: false,
        showFormulaBar: false,
        showSheetTabs: false,
        sheets: sheet,
        created: () => {
            spreadsheet.cellFormat({ textAlign: 'left' }, 'A2:L2');
        },
        cellEdit: function (args) {
            if (args.address.includes('A')) { args.cancel = true; }
        }
    });

    spreadsheet.appendTo('#spreadsheet');

I want to add new row to this spreadsheet. Also, I want to populate the same cell dropdownlist in the new row. How can I achieve it?

Chatra
  • 2,989
  • 7
  • 40
  • 73

1 Answers1

0

Your requirement can be achieved by inserting the rows with predefined rowsModel values using the insertRow method in the contextMenuItemSelect event. For your convenience, we have prepared the sample based on our suggestion, please find the link below.

https://stackblitz.com/edit/3qcicp?file=index.js

We have already demonstrated this in our knowledge base documentation itself. You can find its link below.

https://www.syncfusion.com/kb/13863/how-to-insert-rows-in-the-used-range-with-predefined-values-using-context-menu-option-in