OnAfterRender method execution

Hi Webix Team,

I have created a snippet in which I am trying to add a views dynamically. In this I have use two loops to create the view. I want to bind the data to these text boxes that I have created dynamically. I am trying to add the data binding logic in OnAfterRender method.

Initially when I open a window my OnAfterRender executes. when I hide the window and reopen the window then my OnAfterRender method does not executes as my components are already rendered.

So in such cases is there any other method that can be used instead of OnAfterRender? Or how I can call OnAfterRender method explicitly?

https://webix.com/snippet/474b8a25

Please suggest a solution.

Then how should I bind the data to the text box in such case, where my text box are getting created in dynamic way.

Note my text-box id’s are dynamic.

Hello,

Could you please clarify your use-case a bit?

Basically, onAfterRenderfires on initial rendering (when components appear in DOM) and it is not the best place to apply data-related logic, so first of all, please consider setting the needed values from the separate method right after addView in the same cycle.

As for data binding, this feature works only for data components and form.

Please provide a solution for such scenario.

Hi webix team,
I am also facing same problem.
Please reply.

Thanks

There are two strategies here:

a) catch the moment when widget becomes visible and fill it with data. For form in window, you can use onShow event of the window

https://docs.webix.com/api__ui.window_onshow_event.html

b) you can use bind data to the form by using bind api

form.bind(table);

Now, the form will be filled with data from the selected record. As you have bound data to the form, you can use addView / removeView to change the inputs in the form without any extra handling, all named inputs will be filled with data from the master record.