-
-
Notifications
You must be signed in to change notification settings - Fork 893
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
How to render a fixed-width table with horizontal scroll support #584
Comments
I have read issue #560 The width is 720 in this example which is bigger than screen width. Therefore, I want to have a table with 720px and a scrollable feature to avoid overflow. <table class="lake-table" style="width: 720px;">
<colgroup>
<col width="240" span="1" />
<col width="240" span="1" />
<col width="240" span="1" />
</colgroup>
<tbody>
<tr style="height: 33px;">
<td rowspan="1" colspan="3" style="text-align: center;">
<p><strong>This is a table!</strong></p>
</td>
</tr>
<tr style="height: 33px;">
<td>
<p><br /></p>
</td>
<td>
<p>
</p>
</td>
<td>
<p><br /></p>
</td>
</tr>
<tr style="height: 33px;">
<td>
<p><br /></p>
</td>
<td>
<p><br /></p>
</td>
<td>
<p><br /></p>
</td>
</tr>
</tbody>
</table> |
Can you send a screenshot of how the table looks with your customRender code? I can't visualize it. |
This is the screenshot, it can scroll horizontally, but nothing rendered If I return null, the table will render as normal. |
@erickok is the above intentional? Seems like the customRender doesn't return table children correctly, or maybe it requires more code to render properly? |
It seems you expected What is rendered here is the placeholder which normally isn't shown, being replaced instead by the table. |
Our current workaround is to edit the html content. We wrap each table tag with a custom tag and use the custom renderer for this tag. There it's possible to use a SingleChildScrollView and add the child into it. |
…, allowing to wrap the default implementation
If we supply the element (tree) itself in the render context than you can do something like this:
Does that sound good? The downside there would be that you can't use %-based column widths any more, but I guess that makes sense? You can also wrap the element in a |
However, customRender's function parameter /// The [RenderContext] is available when parsing the tree. It contains information
/// about the [BuildContext] of the `Html` widget, contains the configuration available
/// in the [HtmlParser], and contains information about the [Style] of the current
/// tree root.
class RenderContext {
final BuildContext buildContext;
final HtmlParser parser;
final Style style;
RenderContext({
this.buildContext,
this.parser,
this.style,
});
} my flutter_html version is |
@dreamer2q yes he created the PR #587 to add this property in. If it is merged we will update here accordingly. You can also try out the PR by switching to that branch. |
Good, at least we have a method to solve this, but that's little confusing for me, if we have to hijack the render tree, extra documentation should be provided. |
Yes the docs will definitely be updated, I agree. With 1.3.0 we overhauled the README a whole bunch, likely this use case will go under examples for |
@erickok I think this can be closed. This is shown as an example in the example app, correct? |
Yes, in the readme for 2.0.0 (which is not merged in yet). |
This Works! |
@Sotatek-TanDat6 I believe you can use the For example: Html(
data: html,
style: {
'.se-table-selected-cell > div': Style(
display: Display.none,
),
} |
Hi, guys.
I encountered a problem that when the table has much content, it will overflow horizontally.
Therefore, I want to fix this and tried adding a
SingleChildScrollView
to enable scroll horizontally.You know what, the table content just shrank to one line, although it can scroll horizontally.
I try to make it scrollable
But I seem to break the table rendering, it turns out to be only a container showing
TABLE SECTION
(nothing more here, table content disappeared)So how can I make table scroll horizontally while not breaking it?
Any help is appreciated.
The text was updated successfully, but these errors were encountered: