Can't set default value in dropdownlist

I have a dropdownlist component and the default value is not being set, only the placeholder is shown. The variable list is a list in this format: list= [{name: 'Taylor Abbott', id: 'tabbott'}, {name: "John Smith", id: 'jsmith'}]. Any idea what could be going wrong here? this whole thing is wrapped inside of a FormProvider component from react-hook-form so I'm wondering if that has something to do with it

const itemTemplate = (reviewer) => {
return (<span>{`${reviewer.id} - ${reviewer.name}`}span>)
}

return (
<div style={{ width: '100%', paddingTop: '1%', paddingBottom: '1%' }}>
<DropDownListComponent
id={'dropdown'}
placeholder={'Please select a reviewer'}
dataSource={list}
fields={{ value: 'id', text: 'name' }}
itemTemplate={itemTemplate}
value={'tabbott'}
enabled={true}
/>
div> )

1 Reply

PK Priyanka Karthikeyan Syncfusion Team June 23, 2023 12:39 PM UTC

Hi Taylor,

We have prepared a sample based on your requirement, but we were unable to reproduce the issue in the latest version. In order to better understand the issue you're facing, could you please modify the shared sample according to your scenario and provide us with the steps to replicate the issue, along with a video illustration sample if possible.

Sample:https://stackblitz.com/edit/react-hooks-demo-qq7por?file=index.js,index.html

Regards,

Priyanka K


Loader.
Up arrow icon