Parent/Child rows combined with Template
Parent/Child rows combined with Template
Good morning,
Revisiting my question from early June--which I have spent untold hours researching, what in the parent/child row implementation can possibly be "destroying" or removing the TEMPLATE from the Editor?
I include the "template: "#template-name" statement in the Editor, and it works great--the first time!
When a different parent row is clicked, and the I expand the chile row--the template is blank (and completely missing when inspecting the HTML in DevTools).
(Is there a way to "reapply" the template when the Editor is closed? I don't know if that is an approach.
This question has an accepted answers - jump to answer
Answers
Hi,
Are you referring to this thread? My final comment in there still stands - I'd really need a test case showing the issue to be able to trace through and debug what is going on.
Multiple edits don't appear to be an issue in this example, or in the example in the blog post. I don't have an example online of them together, so perhaps it is something to do with how they are hooked together.
If you can provide a link to a page showing the issue, I can look into it
Allan
Hi Allan,
The reason that I have not posted my code is not because I am ignoring you -- I am working in localhost and have not been successful in publishing using any website.
However, I think that I am on to something!
I was looking at an older post (https://datatables.net/forums/discussion/70960/creating-an-editor-to-view-a-record-with-a-custom-template).
I am combining templates with parent/child rows, where the child row(s) is destroyed each time and rebuilt for the new row! (Unlike the DataTables.net template example.)
Does it not make sense that when we build child rows for the second (and third, etc.) times, the template has already been removed from the HTML??! Therefore, the entire template is already gone, and a blank window displays!
Would there be a fix or workaround for such a situation?
Ah - you mean an entirely new Editor instance?! In that case, that would indeed cause the issue if you are using a string selector for the template, which I looks like you are:
That will need the matching element to be in the DOM so it can be selected.
What to do is to cache the element to a global variable (or otherwise suitability scoped variable) as soon as the page starts up - e.g.:
That will pick the element immediately and store the reference to it. Then when you initialise Editor:
If you have more than one child row being displayed at a time add
.clone()
to thewindow._template
so you are duplicating the element for each instance.Allan
... And he (Allan) hits it out of the field!! (A baseball reference )
I don't know how to thank you!
It may have taken 6 months, but I got to this point due to your enormous repository of questions you've answered!
Unfortunately, with the internet, it's always a question of phrasing the query "just so," in order to get the desired results.
Let me tell you--I have been phrasing and rephrasing for 6 months!
One "artifact" though--each time I open the Editor on a new child row, It displays the Labels and Fields for all of the previous rows that were opened in the Editor!
For example, below, the third time Editor is opened:
Haha - I love baseball. I think this one might have been snagged by a leap at the fence with those multiple fields shown though!
Are you doing:
?
If not, try that.
Allan
Very strange! That solves the issue--but the very first invocation of the Editor comes up blank.
After that it works.
Try:
when initially caching the variable.
Allan
That worked!! -- And it fixed two or three other display-related issues with the Editor forms.
Thank you!
Hurrah - we got there in the end
Allan (pinch hitting in the bottom of the 9th)