The spreadsheet drop down is cutting cut off

1 Reply

JS Janakiraman Sakthivel Syncfusion Team August 7, 2024 02:58 PM UTC

Hi Michael Cheung,

We have reviewed your reported problem based on the image and sample you shared. We kindly inform you that if more than 255 characters are entered in the list validation source in MS Excel, it restricts further entry, and the validation is not applied. This is the default behavior of MS Excel. We have done the same exact scenario on our end. For more details, please refer to the below link.

https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3?ui=en-us&rs=en-us&ad=us#ID0EDBD=Office_2010

However, we can achieve your requirement with help of the providing the cell range collection. We have prepared a sample to meet your requirement. In this sample, we have maintained the list validation data in another sheet named "Dropdown Data". We then referenced the range of cells containing this data from the "Dropdown Data" sheet in the addDataValidation method for the parameter "value1", as highlighted in the code snippet shared below to achieve your requirement.

For your reference, we have modified your shared sample and included it along with the code snippet below.

Sample: https://stackblitz.com/edit/yhas15-ped9eu?file=index.ts,drop-down-data.json

CODE SNIPPET:


let spreadsheet: Spreadsheet = new Spreadsheet({

  sheets: [

    {

      name: 'Car Sales Report',

      ranges: [{ dataSource: (dataSource as any).defaultData }],

    },

    {

      name: 'Dropdown Data',

      ranges: [{ dataSource: dropdownData }],

    }

  ],

created: (): void => {

    spreadsheet.addDataValidation(

      {

        type: 'List',

        inCellDropDown: true,

        value1: '=Dropdown Data!A2:A20'

      },

      'A2:A10'

    );

  },

});


In the above sample, 'Dropdown Data' sheet
contains the list of values in the cell range A2: A20. We have mapped this data collection to the list validation data collection.

In addition, if you would like, you can automatically adjust the width of the list validation's dropdown list based on its content by setting the width to "auto" for the dropdown list's popup element at the CSS level, as highlighted in the code snippet below. We have used the "id" of the dropdown list's popup element in the CSS.

For your reference, we have modified your shared sample and included it along with the code snippet below.

Sample: https://stackblitz.com/edit/yhas15-jazuvy?file=index.ts,index.html

CODE SNIPPET:


index.html:

<style>

        [id$="listValid_popup"] {

               width: auto !important;

        }

</style>


Kindly check the details shared above on your end and get back to us if you need further clarifications regarding this. We hope this helps.


Loader.
Up arrow icon