How can I bind my dropdownlist to a WebAPI call?

1 Answer 100 Views
DropDownList
Brian
Top achievements
Rank 1
Brian asked on 14 Sep 2022, 09:17 PM | edited on 14 Sep 2022, 09:18 PM

I've tried several iterations, and something isn't right. If I type the endpoint in a browser, I get a Json result. Swagger shows the API returning stuff. No luck with the DropDownList yet.

Here is my current markup on the client:


    <div>
        <kendo-datasource name="data" type="DataSourceTagHelperType.WebApi" server-operation="true">
            <transport>
                <read url="https://localhost:7225/api/SievePack" action="get" datatype="jsonp"/>
            </transport>
            <schema>
                <model id="SieveSetId">
                    <fields>
                        <field name="SieveSetId" type="number" />
                        <field name="SieveSetName" type="number" />
                    </fields>
                </model>
            </schema>
        </kendo-datasource>

        <script>
            data.read();
        </script>
        
        <kendo-dropdownlist name="sets"
                            datatextfield="SieveSetName"
                            datavaluefield="SieveSetId"
                            datasource="data">
        </kendo-dropdownlist>

    </div>

I have the API solution running when I launch the client.

Do I need to do something in another part of my application? From what I've been reading, this should work..

Thanks!

1 Answer, 1 is accepted

Sort by
0
Mihaela
Telerik team
answered on 19 Sep 2022, 02:11 PM

Hello Brian,

Since you have submitted the same query as a support ticket, I will post my answer here in case someone else experiences a similar issue:

Would you please update the attribute "datasource" to "datasource-id" as per the example below?

        <kendo-dropdownlist name="sets"
                            datatextfield="sieveSetName"
                            datavaluefield="sieveSetId" datasource-id="data">
        </kendo-dropdownlist>

Attached is a runnable sample for your reference.

 

Regards, Mihaela Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Brian
Top achievements
Rank 1
commented on 19 Sep 2022, 10:23 PM

Thank you. I did eventually do this, and it's working. I thought I'd closed out that ticket, but you can do so if I didn't do it properly.
Mihaela
Telerik team
commented on 20 Sep 2022, 01:43 PM

Thank you for your confirmation, Brian.

If any related questions pop up, feel free to share them.

Tags
DropDownList
Asked by
Brian
Top achievements
Rank 1
Answers by
Mihaela
Telerik team
Share this question
or