React-sortable-tree: Dynamic row height depending on amount of lines in text

Created on 25 May 2020  路  12Comments  路  Source: frontend-collective/react-sortable-tree

how can the height of the items be set dynamically based on the text size (e.g. number of lines or calculated item height)?

Most helpful comment

Please take a look at this PR https://github.com/frontend-collective/react-sortable-tree/pull/774. I solved the dynamic row height and I will look forward to your suggestions now.

All 12 comments

@pixxelia did you get any solution for this?

@pixxelia did you get any solution for this?

no :-( did you?

@pixxelia did you get any solution for this?

no :-( did you?

Not yet 馃憥

will take a look

Thanks @lifejuggler
It would be better if we get the same for the width.

I don't follow @anil1712 why we'd need dynamic row width

I don't follow @anil1712 why we'd need dynamic row width

Please see the attached screenshot, in my case the texts are getting overlapped.
Screen Shot 2020-06-20 at 11 28 10 PM

So may be if we manage the width based on the content then it would be better

maybe but if I do add the width its not going to be for this issue

Looking forward to getting this fixed. The usability is lost when one uses the plugin to render dynamic components.

Please take a look at this PR https://github.com/frontend-collective/react-sortable-tree/pull/774. I solved the dynamic row height and I will look forward to your suggestions now.

How do we achieve the dynamic height?

We can use some dirty solution, while PR #774 not merged.

Create a custom theme based on default theme.
Add custom attribute to element with rst__rowLabel class with treeIndex value.

 <div className={classnames('rst__rowLabel', rowDirectionClass)} dataid={treeIndex}>

Write rowHeight function

rowHeight: ({ treeIndex }) => {
    const treeEl = document.querySelector(`[dataid="${treeIndex}"]`);
    return treeEl ? treeEl.offsetHeight : 0;
  },

Do not forget change rst__rowLabel class, so that it has the height of the content.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vladimirsvsv77 picture vladimirsvsv77  路  5Comments

NickEmpetvee picture NickEmpetvee  路  3Comments

29er picture 29er  路  5Comments

mcolburn picture mcolburn  路  4Comments

LogicMonsters picture LogicMonsters  路  5Comments