Hi,
I have a hard time trying to append a simple button to each of the items of the dataview widget that are generated on data store update.
My code is too lengthy to display it here, but this is what is going on:
-
The template function of the “dataview” takes care of processing the data object and generating HTML:
template: function() {
…
} -
Upon external button click (“onItemClick”) the data store of the “dataview” gets updated (add()) from the output of the Ajax call.
//outside the “dataview”
on: {‘itemClick’:function() {
$$(“mycontainer”).add(someData);
}
}; -
Inside the “dataview” I define “onItemRender” event: once the dataview item is rendered, I want to append to it a button by calling the webix addView() function. I don’t manage, though, to select properly the html container of the rendered dataview object item:
a. the callback of the “onItemRender” returns data object: I can obviously access its id, but I didn’t manage to add to them by using any of the id functions;
b. the “this” of the “onItemRender” returns the entire widget: I tried to access its children etc., but failed to add the view to them.
c. the HTML containers of the data object don’t seem to be accessible through $$(id), “f_webix_id” etc.
//inside the “dataview”
on: {‘onItemRender’:function(item) {
this.getItem(item.id).addView(…); //doesn’t work
this.addView({view:“button”,value:“AAA”},1); //doesn’t work
$$(item.id)… //doesn’t work (parentView() etc.)
}
}
My question is then: how one should approach the problem of adding a HTML code / views to the items of the dataview and similar widgets? Are they supposed to be used in this way? Is one supposed to hardcode it in the template and then? What about the dynamic ids that one cannot define while the template is getting defined?