This is a migrated thread and some comments may be shown as answers.

Databinding async methods

6 Answers 2102 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
ksuh
Top achievements
Rank 1
Veteran
ksuh asked on 16 Nov 2020, 04:10 PM
     Is it possible to databind methods that are async?  I have a method that does an axios call that must be async, thus making the databinding call async.

6 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 18 Nov 2020, 11:39 AM

Hello,

See the following thread on stackoverflow, which discusses such scenario: https://stackoverflow.com/questions/52247040/kendo-datasource-reading-from-async-await-method-which-uses-axios-to-fetch-data

Regards,
Ivan Danchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
ksuh
Top achievements
Rank 1
Veteran
answered on 30 Nov 2020, 06:00 PM

Unfortunately not useful at all, I am not binding to a datasource.

Async/await has been around for years in Javascript, a disappointment at the extremely limited support for it in Kendo UI.

0
ksuh
Top achievements
Rank 1
Veteran
answered on 02 Dec 2020, 12:07 AM

I was able to create a custom binding to make it work.

They really should be built-in, they're trivial to implement.

0
ksuh
Top achievements
Rank 1
Veteran
answered on 02 Dec 2020, 12:08 AM
kendo.data.binders.textAsync = kendo.data.Binder.extend({
        refresh: async function ()
        {
            const text = await this.bindings['textAsync'].get();
 
            const dataFormat = this.element.getAttribute("data-" + kendo.ns + "format") || "";
 
            if (text == null)
            {
                text = '';
            }
 
            $(this.element).text(kendo.toString(text, dataFormat));
        }
    });
0
ksuh
Top achievements
Rank 1
Veteran
answered on 02 Dec 2020, 12:14 AM
Ok, so binding something like text is simple.  However, doing async events is another matter.  Those really should be implemented by you guys.
0
Ivan Danchev
Telerik team
answered on 02 Dec 2020, 10:45 AM

Hello Ksuh,

Thank you for sharing your approach with the community. This feature hasn't been requested yet: https://feedback.telerik.com/kendo-jquery-ui , thus we don't have data on what the interest in it is, to plan it accordingly.

Regards,
Ivan Danchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
MVVM
Asked by
ksuh
Top achievements
Rank 1
Veteran
Answers by
Ivan Danchev
Telerik team
ksuh
Top achievements
Rank 1
Veteran
Share this question
or