I am wondering if it’s possible to create a child table as a virtual doctype.
So technically it works: I mean, I can create the DocType with the Flags:
x Virtual
x Child Table
The generated .py file has the methods:
db_insert
db_update
get
get_list
get_count
get_stats
I expected to implement get_list() to return the values I want to display.
I just want to aggregate some other data in another block, which are already persisted in the database.
So I thought that might be the easiest way … but I cannot find anything about that in the docs or in the forum… so I hope somebody can help me.
The current result is →
The child table is embedded at the parent doctype but with empty entities.
I’ve called frappe.logger() within the method get_list(), which doesnt log anything.
So it seems, that there needs to be another method to be redefined to gather the Child Table’s data… hope anybody did this already?
This is a really interesting idea. Among other things, it suggests a way to get real table joins through the regular form interface. Last I check in v13, virtual doctypes were still only half implemented, but I’ve heard it’s working more fully in the v14 betas. What version are you testing on?
The event’s method will then not be called in the “this” scope.
But I cannot use this.events.load_data.bind(this) as it would generate an anonymous function, which would then be bound additionally to the click, each time another refresh appears.
So my loading function doesn’t care about its scope, which made it ok.
Otherwise you could memoize the anonymous function to get the same effect, but as I previously mentioned, I don’t have enough experience with frappe to know about the instance lifecycles.
I didn’t find a “real” attribute for the current indication of collapse/expand, that’s why I triggered the DOM element’s class… again a kind of ugly.
If there a better ways for that, it would really be useful to have this in the docs.
Very strange… but unfortunately I encountered further trouble when persisting/deleting the parent doctype.
Opened a PR for that… hope this will get reviewed soon, but for now I have to disable that feature because of that.