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

Call function after listview template was loaded?

3 Answers 516 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 16 Dec 2015, 02:26 PM

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.

3 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 18 Dec 2015, 12:26 PM
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!
 
0
Steve
Top achievements
Rank 1
answered on 18 Dec 2015, 01:19 PM

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.

0
Alexander Valchev
Telerik team
answered on 22 Dec 2015, 10:20 AM
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!
 
Tags
ListView
Asked by
Steve
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Steve
Top achievements
Rank 1
Share this question
or