How can i copy/paste text from ComboBox

Posted by: ngocnguyen09910060 on 10 February 2022, 11:10 am EST

    • Post Options:
    • Link

    Posted 10 February 2022, 11:10 am EST

    Hi teams,

    On my web application, i setting: clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values

    I have a combobox with editorValueType = value.

    Now, i want to copy/paste text from combobox to another cell but it copy/paste value.

    How can i do it ?

  • Posted 11 February 2022, 7:33 am EST

    Hi,

    We have tested with clipboardOptions set to GC.Spread.Sheets.ClipboardPasteOptions.values and comboBox editor value type is set to EditorValueType.value and it seems to be working fine. You can Simply copy/paste using Ctrl+C/Ctrl+V or use the context menu to copy the cell and paste into another cell(paste value).

    Please refer to the following sample and let us know if you face any further issues: https://jscodemine.grapecity.com/share/VhYltUsgUkuvGgPWM7T_-Q/

    Regards

  • Posted 11 February 2022, 12:23 pm EST

    Hi ankit.kumar,

    In your sample, when i paste, result is: 11k/15k/100k.

    I want to paste text: Oranges/Apples/Grape.

    How can i do it ?

    Regards

  • Posted 14 February 2022, 1:39 am EST

    Hi,

    For this, you need to change the editValueType to text. Please refer to the following code snippet and let me know if you face any issues.

    
     var combo = new spreadNS.CellTypes.ComboBox();
        combo.items([{ text: "Oranges", value: "11k" }, { text: "Apples", value: "15k" }, { text: "Grape", value: "100k" }])
            .editorValueType(spreadNS.CellTypes.EditorValueType.text);
        sheet.getCell(1, 2, spreadNS.SheetArea.viewport).cellType(combo).value("Oranges");
    
    

    API:

    editorValueType: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.CellTypes.ComboBox~editorValueType.html

    Regards,

    Avinash

  • Posted 14 February 2022, 10:57 pm EST

    Hi ankit.kumar,

    If i using EditorValueType.text, when end user click button Save, i get value of cell:

    sheet.getCell(idxRow, idxCell).value()

    it return Oranges/Apples/Grape. But i want to call API Save with 11k/15k/100k.

    Please help me.

    Regards

  • Posted 15 February 2022, 1:06 am EST

    Hi,

    editorValueType sets the value that is written to the underlying data model. You can use the sheet.getValue() to get the value of the underlying data model.

    Considering your use case, you can override the copy command so that it will paste the text when copy/pasting the combobox and get you the combobox’s value using sheet.getValue()

    getValue Method: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Worksheet~getValue.html

    Please refer to the sample that I have created for you and let us know if you face any further issues: https://jscodemine.grapecity.com/share/nIRGfOaqJkCiJuhPgUAuBg/

    Regards.

  • Posted 16 February 2022, 8:38 am EST

    Hi ankit.kumar,

    I have downloaded your sample code and started success.

    But my project is using TypeScript and when i apply your code:

    oldFn.apply(this, arguments);
    

    I get error:

    Argument of type 'IArguments' is not assignable to parameter of type '[context: Workbook, options: { sheetName: string; }]'.
    

    Please help me.

  • Posted 17 February 2022, 1:36 am EST

    Hi,

    You can overcome this error by simply using```

    (oldFn as any).apply(this, arguments);

    
    Regards.
  • Posted 17 February 2022, 7:44 am EST

    Hi ankit.kumar,

    It work fine.

    Thank you very much.

Need extra support?

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

Learn More

Forum Channels