Using ListComboEditor in Dialog Template

Posted by: m.holland-moritz on 28 January 2021, 9:05 am EST

    • Post Options:
    • Link

    Posted 28 January 2021, 9:05 am EST

    Hello everyone!

    I ran into a problem, i can’t find a solution.

    Current szenario:

    I created a dialog template with multiple List Combo Editor. With this Combos, the user should select the language. By Default it should be on german/deutsch. How can i set this Item as default item, and show it’s text in the dialog?

    My ListComboEditor template is like this: (dict. is just a dictionary i use to fill in diffrent strings per language)

    type: “ListComboEditor”,

    items: [

    {

    text: dict.lang_DE,

    value: “DE”,

    type: “listItem”,

    }, {

    text: dict.lang_ENG,

    value: “EN-GB”,

    type: “listItem”,

    selected: true

    }, {

    text: dict.lang_ENU,

    value: “EN-US”,

    type: “listItem”,

    },{

    text: dict.lang_FR,

    value: “FR”,

    type: “listItem”

    }, {

    text: dict.lang_IT,

    value: “IT”,

    type: “listItem”,

    }, {

    text: dict.lang_JA,

    value: “JA”,

    type: “listItem”,

    }, {

    text: dict.lang_ES,

    value: “ES”,

    type: “listItem”,

    }, {

    text: dict.lang_NL,

    value: “NL”,

    type: “listItem”,

    }, {

    text: dict.lang_PL,

    value: “PL”,

    type: “listItem”,

    }, {

    text: dict.lang_PTP,

    value: “PT-PT”,

    type: “listItem”,

    }, {

    text: dict.lang_PTB,

    value: “PT-BR”,

    type: “listItem”,

    },{

    text: dict.lang_RU,

    value: “RU”,

    type: “listItem”,

    }, {

    text: dict.lang_ZH,

    value: “ZH”,

    type: “listItem”,

    }

    ]

    I though i can do it with selected, but that only ends in a selected item, when the user opens the combobox.

    Can somebody help?

    Best regards

    Maik

  • Posted 29 January 2021, 3:47 am EST

    Hi Maik,

    You need to set the value of the cell for selecting that item in a ComboBox. Please refer to the following code snippet and attached sample that demonstrates the same.

    
     var combo = new GC.Spread.Sheets.CellTypes.ComboBox();
      sheet.setCellType(3, 2, combo, GC.Spread.Sheets.SheetArea.viewport);
      combo.items([
        { text: "Oranges", value: "11k" },
        { text: "Apples", value: "15k" },
        { text: "Grape", value: "100k" }
      ]);
      sheet.setValue(3, 2, "Apples");
    
    

    sample: https://codesandbox.io/s/cranky-pasteur-uwxo7?file=/src/index.js

    ComboBox Demo: https://www.grapecity.com/spreadjs/demos/features/cells/cell-types/combobox#demo_source_name

    Regards

    Avinash

  • Posted 29 January 2021, 5:28 am EST

    Thanks for your reply, but thats not exactly what i meant.

    I am not talking about the Combobox Celltype.

    I am using the designer components for spreadjs and i want to open a dialog with some ListComboEditors in it.

    With a custom button i open this dialog, but all Comboboxes are empty and i cant find how to set the initial or default Value of these.

    Best regards

    Maik

  • Posted 29 January 2021, 6:27 am EST

    Hi Maik,

    Thanks for the information. this feature is currently not supported. Further, We have made an enhancement request on your behalf. We will update you regarding this as soon as we get any information. The internal ID for this issue will be SJS-7461.

    Regards

    Avinash

  • Posted 21 December 2021, 1:42 am EST

    Hi Amik,

    for this, you may override the listCellType command. please refer to the following code snippet and let me knwo if you face any issues.

    
    var newListCellTypeCommand = GC.Spread.Sheets.Designer.getCommand('listCellType');
    		var oldCommandExecuteFn = newListCellTypeCommand.execute;
    		newListCellTypeCommand.commandName = "myListCellType";
    		newListCellTypeCommand.execute = function (context, propertyName) {
    			var ret = oldCommandExecuteFn.apply(this, arguments);
    			ret.then(function () {
    				var workbook = context.getWorkbook();
    				var sheet = workbook.getActiveSheet();
    				sheet.getCell(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()).value("any value you want");
    			})
    			return ret;
    		}
    
    
    

    Regards

    Avinash

Need extra support?

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

Learn More

Forum Channels