Databinding async methods

7 posts, 0 answers
  1. ksuh
    ksuh avatar
    52 posts
    Member since:
    Jul 2006

    Posted 16 Nov 2020 Link to this post

         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.
  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    2187 posts

    Posted 18 Nov 2020 Link to this post

    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/.

  3. ksuh
    ksuh avatar
    52 posts
    Member since:
    Jul 2006

    Posted 30 Nov 2020 Link to this post

    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.

  4. ksuh
    ksuh avatar
    52 posts
    Member since:
    Jul 2006

    Posted 01 Dec 2020 Link to this post

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

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

  5. ksuh
    ksuh avatar
    52 posts
    Member since:
    Jul 2006

    Posted 01 Dec 2020 Link to this post

    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));
            }
        });
  6. ksuh
    ksuh avatar
    52 posts
    Member since:
    Jul 2006

    Posted 01 Dec 2020 Link to this post

    Ok, so binding something like text is simple.  However, doing async events is another matter.  Those really should be implemented by you guys.
  7. Ivan Danchev
    Admin
    Ivan Danchev avatar
    2187 posts

    Posted 02 Dec 2020 Link to this post

    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/.

Back to Top