Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'className')

Hello Syncfusion support,

Im trying to create dropdown list with multiple select options.

$('#dropdown').ejDropDownList({

dataSource: [{ Name: "test1", id: 1 }, { Name: "test2", id: 2 }],

selectedIndices: [2],

fields: { text: 'Name', value: 'id' },

enabled: true,

showCheckbox: true,

width: '100%',

watermarkText: 'Select options',

enableFilterSearch: true,

showRoundedCorner: true

});

when I add selectedIndices: [2] property I got this error, but when I remove it the error disappears.

Can you please tell me what is the issue, knowing that I want to add selectedIndices property.


below is the error:


Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'className')

at Object._hasClass (ej.web.all.min.js:10:1244701)

at Object._isChecked (ej.web.all.min.js:10:1288041)

at Object._enterTextBoxValue (ej.web.all.min.js:10:1258454)

at Object._selectCheckedItem (ej.web.all.min.js:10:1249080)

at Object._finalize (ej.web.all.min.js:10:1213095)

at Object._render (ej.web.all.min.js:10:1216088)

at Object._init (ej.web.all.min.js:10:1203805)

at new (ej.web.all.min.js:10:22664)

at n.fn.init.n.fn. [as ejDropDownList] (ej.web.all.min.js:10:23921)

at projects.js:24:35


Thank you.




1 Reply

KR Keerthana Rajendran Syncfusion Team April 28, 2022 09:15 AM UTC

Hi Ali Ossaily,


Greetings from Syncfusion support.


We have noticed that the proper index is not mapped to the selectedIndices property in your code. This property in the DropDownList component represents the item's index to be selected. The item index starts from 0 since the array has only 2 items, index 2 will be null and hence the error occurs.

To resolve this, please give the available index for selection(For ex: [1])

Sample: https://jsplayground.syncfusion.com/qusunqj4

You can refer to the below API link for further reference.

https://help.syncfusion.com/api/js/ejdropdownlist#members:selectedindices

Please let us know if any concerns.


Regards,

Keerthana R.


Loader.
Up arrow icon