-
Notifications
You must be signed in to change notification settings - Fork 262
outernode
and node
documentation for developers
#552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Haha. I will update these docs to make the use more clear. Basically, most widgets have the same value for I can see how in your case the |
I don't know if I use them correctly. Table.pyclass TableWidget(flx.Widget):
def _create_dom(self):
node = flx.create_element('tbody')
outernode = flx.create_element('table', {}, [node])
return [outernode, node]
class TableEntry(flx.Widget):
def _create_dom(self):
return flx.create_element('tr')
class TableEntryAttribute(flx.Widget):
text = flx.StringProp(
settable = True, doc = "The text shown for this attribute."
)
def _create_dom(self):
return flx.create_element('td', {}, [self.text]) Main widgetclass EstimatesView(flx.Widget):
data = flx.ListProp(doc = "The data shown by the view.")
def init(self):
super().init()
with widgets.TableWidget():
for datum in self.data:
with widgets.TableEntry():
widgets.TableEntryAttribute(text = datum.id)
widgets.TableEntryAttribute(text = datum.name)
widgets.TableEntryAttribute(text = datum.client)
widgets.TableEntryAttribute(text = str(datum.total))
widgets.TableWidget() Rendered HTML<div class="flx-EstimatesView flx-Widget flx-current">
<table class="flx-TableWidget flx-Widget">
<tbody></tbody>
<tr class="flx-TableEntry flx-Widget">
<td class="flx-TableEntryAttribute flx-Widget">D-000255</td>
<td class="flx-TableEntryAttribute flx-Widget">Culpa esse cupidatat id elit dolor adipisicing</td>
<td class="flx-TableEntryAttribute flx-Widget">Aliqua ullamco</td>
<td class="flx-TableEntryAttribute flx-Widget">2533.25</td>
</tr>
<!-- more <tr> -->
</table>
</div> Here, the point is that the Is it expected ? I expected them to be added to the |
This is expected. The default implementation of def _render_dom(self):
# todo: ... clear self.node's children
for widget in self.children:
self.node.appendChild(widget.outernode)
return create_element("table", {},
create_element("thead", {}, ...),
self.node
) Actually, I think it may be easier to not use a different class TableWidget(flx.Widget):
def _create_dom(self):
return flx.create_element('table')
def _render_dom(self):
return create_element("table", {},
create_element("thead", {}, ...),
create_element("tbody", {}, [widget.outernode for widget in self.children])
) (Flexx re-uses DOM elements if the virtual node matches the existing one.) |
Also note that Flexx will soon have a |
Good. But here, I'm using a About that, I think implementing that layout using a |
Thanks for your help. |
Indeed, in that case a table makes more sense. |
Hi.
I successfully implemented a table widget using the Python way (by using a root
TableWidget
and multipleTableEntry
) and the web way (by using a singleTable
widget and a dataListProp
).But I'm trying to understand the way
outernode
andnode
properties can be used.Can I use the
outernode
for thetable
DOM element and thenode
for thetbody
DOM element (which will contain the children) ?Broadly speaking, the documentation says about those properties:
OK. I think I need to understand what this is about. 😉
Thanks.
The text was updated successfully, but these errors were encountered: