Quesions about spreadsheet dropdown list features

Hello,

I have an example like this: http://jsplayground.syncfusion.com/jsmc2fst

I would like to know, 

  1. How can I assign the value from the "data" object to the "dropdown list" as the selected value?  When the data is loaded, the "dropdown" value is not selected.(First question.jpg)
  2. There is an example in the link: https://help.syncfusion.com/api/js/ejspreadsheet#methods:xlcelltype-addcelltypes I couldn't understand how can I use the "field" parameter. Does "field" parameter always have to be "text"?
  3. How can I get the value of "itemId" like in "itemList" object from the value selected in "dropdown"? Currently, I can only see an automatically assigned "id" in the "cellSave" function.  You can check from this line in the "save cell" function : console.log(args); (Third question.jpg) 
Thank you in advance
Bahar

Attachment: questionImages_fd1e8554.zip

5 Replies 1 reply marked as answer

SP Sangeetha Priya Murugan Syncfusion Team November 11, 2020 01:21 PM UTC

HI Bahar Gulse, 
 
Thank you for contacting Syncfusion support. 
 
Requirement #1: How can I assign the value from the "data" object to the "dropdown list" as the selected value?  When the data is loaded, the "dropdown" value is not selected.(First question.jpg) 
 
We have checked your requirement and it can be achievable by setting the selectedIndex property as like in the below code example. 
 
excelObj.XLCellType.addCellTypes("A"+counter, { 'type': ej.Spreadsheet.CustomCellType.DropDownList, 'dataSource': itemList, 'field': { id: "itemId", text: "text" }, selectedIndex: 0}); 
 
Requirement #2:  I couldn't understand how can I use the "field" parameter. Does "field" parameter always have to be "text"? 
 
Based on your datasource for dropdownlist element you need to set the field property for mapping the list item. For more details regarding this. Please refer the below link. 
 
 
Requirement #3: Currently, I can only see an automatically assigned "id" in the "cellSave" function. 
We have checked your requirement and it can be achievable in our spreadsheet by using the getSelectedItemsID dropdownlist method as like as below in cellSave event. 
 
  function cellSave(args) { 
     var drpDownId = this.getCell(args.cellIndex.rowIndex, args.cellIndex.colIndex)[0].querySelector("input").id; // get dropdownlist id 
      var DropDownListObj  = $("#" + drpDownId).data("ejDropDownList"); // get dropdownlist instance 
        var itemId = DropDownListObj.getSelectedItemsID()[0]; // to get the selected item text 
     console.log(itemId) 
    } 
 
For your convenience, we have prepared the sample based on your requirement. Please find the link below. 
 
 
Please let us know if you need further assistance on this. 
  
Regards, 
Sangeetha M 


Marked as answer

BG Bahar Gulse November 12, 2020 01:39 PM UTC

Hello Sangeetha M,

Thank you for the information and the link. Your example solved all of my questions. 

Regards,

Bahar


SP Sangeetha Priya Murugan Syncfusion Team November 13, 2020 04:36 AM UTC

HI Bahar Gulse, 
 
Thank you for your update.  
 
We are happy to hear you. Please feel free to contact us, if you need any further assistance on this. 
  
Regards, 
Sangeetha M 



GO gofeatureus July 27, 2022 08:29 AM UTC

what are the feature support in latest version



SP Sangeetha Priya Murugan Syncfusion Team July 29, 2022 08:43 AM UTC

Hi gofeatureus,


We suspect that you need of cell template support in EJ2 Spreadsheet. For more details, please refer the below links.


Demo Link: https://ej2.syncfusion.com/demos/#/bootstrap5/spreadsheet/cell-template.html


Documentation Link: https://ej2.syncfusion.com/documentation/spreadsheet/template/


Could you please check the above links and get back to us, if you need any further assistance on this.


Regards,

Sangeetha M


Loader.
Up arrow icon