How do I populate the DropDownList in Your Tutorial?

0 Answers 51 Views
DropDownList
Doug
Top achievements
Rank 2
Iron
Iron
Iron
Doug asked on 07 Sep 2023, 04:12 PM | edited on 07 Sep 2023, 04:16 PM

In your Chapter 04 video #3

I'm trying to change this JSX from:

              <select className="form-control" defaultValue={newItem.typeStr} onChange={(e) => onFieldChange(e, "typeStr")} name="itemType">
                {itemTypesProvider.map((t) => {
                  return (
                    <option key={t} value={t}>
                      {t}
                    </option>
                  );
                })}
              </select>

 

To its equivalent: 

              <DropDownList
                data={itemTypesProvider} defaultValue={newItem.typeStr}
                onChange={(e) => onFieldChange(e, "typeStr")}
                name="itemType"></DropDownList>

 

As you can see, the expression to map the itemTypesProvider array is missing from the KendoReact component.

Adding a child, between the the <DropDownList></DropDownList> tags is not permitted.

              <DropDownList
                data={itemTypesProvider} defaultValue={newItem.typeStr}
                onChange={(e) => onFieldChange(e, "typeStr")}
                name="itemType">Anything between the opening and closing tags results in an error</DropDownList>

 

(Please see attachment)

How do I get the itemTypesProvider items to populate my DropDownList?

Doug
Top achievements
Rank 2
Iron
Iron
Iron
commented on 07 Sep 2023, 04:17 PM

I updated the example code to include data={itemTypesProvider}
Wissam
Telerik team
commented on 11 Sep 2023, 10:42 AM

Hi, Doug,

The DropDownList does not have a children prop and its values are passed to its `data` property which you applied in the example.

I can understand that you were able to fix the issue. Is this correct? If you require further help with the DropDownList, please let me know.

Regards,
Wissam
Progress Telerik
Doug
Top achievements
Rank 2
Iron
Iron
Iron
commented on 12 Sep 2023, 02:19 PM

Wissam,

Yes, I was able to fix the issue.

Doug

No answers yet. Maybe you can help?

Tags
DropDownList
Asked by
Doug
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or