Call function after listview template was loaded?

4 posts, 0 answers
  1. Steve
    Steve avatar
    17 posts
    Member since:
    Oct 2014

    Posted 16 Dec 2015 Link to this post

    Hi,

    we're using Kendo UI with the MVVM implementation for on of our web applications (SPA) and I have a question regarding the list view.

    To provide the option to change the language on the fly, we're using a script library that basically looks for html-elements with a specific attributes replaces their text with a string based on the value of the attribute and the current culture you selected. To trigger this, a function needs to be called that translates the current document.

    Now this wasn't problem so far, since I always found the right places to trigger the translation, but now I'm at a loss with the ListView templates. Both the data and the edit template have such tags that need to translated (<dl> tags to be specific). Basically what needs to happen is the following:

    1. Site loads -> ListView loads -> Template is loaded and filled via a dataSource -> Translate the Template after loading finished
    2. Click on Edit or Add -> ListView loads EditTemplate -> Translate the EditTemplate
    3. Click Save in Edit -> ListView loads Template -> Translate the Template
    4. Click on Cancel in Edit -> ListView loads Template -> Translate the Template

    Cases 1-3 are no problem.

    1. Hook into the dataBound event, Template is loaded, start translation
    2. Hook into the edit event, EditTemplate is loaded, start translaton
    3. Hook into the save event, Template is loaded, start translation
    4. Now I know can hook to the cancel event but here's the problem: Hook into the cancel event, Template is not loaded, translation starts, Template is loaded

    The cancel event, unlike the other events, fires before the template is loaded. So the translation runs, but at this point the Template is not loaded and therefore not translated.

    Is there any way to do this? The best option (which I could not find on the internetz) would be to hook into the "load template" event if there is one or simply any other possibility to call this translation after the template loaded.

    I tried many other ways and many other events - my best option was to bind to the "DOMSubTreeModified" event, but that backfires (literally) because the translation algorithm also modifies the subtree :/

    Any solution would be appreciated.

  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 18 Dec 2015 Link to this post

    Hello Steve,

    There is no suitable event that you may use. My suggestion is to execute the code at the cancel event within a setTimeout(). There is no need to specify the timeout, even value of 0 should do the job.

    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Steve
    Steve avatar
    17 posts
    Member since:
    Oct 2014

    Posted 18 Dec 2015 in reply to Alexander Valchev Link to this post

    Hi Alexander,

    good call, I didn't even think of the setTimeout() function. I still don't like that I have to hook into so many events to do the same thing but until we come up with a better solution, this works. Thanks for that.

    There came up one more issues working with the ListView and I was wondering if you could help me with this one, too:

    In our ListView, you can add credentials, so there are inputs for Domain, Username, Password per item. The ListView is set to be navigatable, using the built-in events from Kendo UI. So for example if you press Enter while editing an item it should attempt to save it. This works fine, but only when you're within the Domain or Username input. The event doesn't seem to get handled when you're in the Password input. Pressing Enter does nothing, which is unfortunate, since it's - understandably - the last input the user will normally edit. Is this because the input has the type='password' attribute or what could be the reason it's not reacting to the Enter keypress? If that's the case, is only our option to manually attach an event handler and trigger dataSource.sync()?

    Thanks again for your help.

    Regards,

    Steve.

  5. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 22 Dec 2015 Link to this post

    Hi Steve,

    Please open a new support ticket/forum thread for the new issue that you need help with.
    We will review the case and assist you, but not in this thread. We prefer to keep separate questions in separate threads due to many reasons - this makes it easier to track the support history in case the scenario is forwarded to another staff member or in case another customer reads the thread. In addition this makes it easier to focus on the concrete issue which usually leads to its faster resolving.

    Thank you in advance for the understanding.

    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready