How do I iterate over a container with KendoUI widgets and get their values using jQuery?

159
April 13, 2018, at 11:45 PM

I'm working with jQuery and KendoUI for MVC. I have a ul called #overview and each list item has a different kind of KendoUI widget in it. Those widgets are the like of text boxes, multi select, ranger sliders and dropdown lists. There is a button that the user can click which runs a jQuery function to gather the content of all these widgets.

The problem I have is that these widgets have Kendo specific code to access their values and text attributes such as $("MyControl").data("kendoDropDownList).text();, I am using a .each loop to iterate over the li and I need a way to grab the data from the varying controls and I was wondering if there was a clean way to do that?

With so many controls available it will make for a complex piece of code to check for every possible control that may be there.

Any help is appreciated.

Answer 1

This is kinda tricky. There is an obscure method called kendo.widgetInstance() that whatever element you pass intto it, it will check for a widget and return it's instance.

var $date = $("#date").kendoDatePicker({ value: (new Date()) });
console.log(kendo.widgetInstance($date).value());

Demo

READ ALSO
how to compare two input values in a table jquery

how to compare two input values in a table jquery

I would like to know how to compare two values of two rows in a dynamic table that is created in PHP with the same id

186
Hover and click

Hover and click

I have 4 same div-s like this, when I hover over one of the link all the elements get the same codePlease help with my code

165
jQuery each always returns last value

jQuery each always returns last value

How can I stop theeach() selecting the last value each time it runs?

167
Build an simple index.html file including few parameters from Postman

Build an simple index.html file including few parameters from Postman

I'm using postman to send the Notification to my android appBut I want to know how to build an simple index html file with required necessary fields and host in my hosting site and send via that one

116