最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

In react-native how to create table view with vertical as well as horizontal scroll - Stack Overflow

programmeradmin1浏览0评论

In a react-native, I have to create a table View which should match the following conditions:

  1. The first row should be the header where the First & last Items should be sticky and items in the centre can be horizontally scrollable, also, the header should be sticky for vertical scroll.
  2. From the second row onwards we will have actual data where again, the First & last Items should be sticky and items in the centre can be horizontally scrollable.
  3. Other than the header table, it should be vertically scrollable including the first & last item of each row, also when scrolling vertically it should look like the complete row is scrolling together.
  4. Also when the user scrolls horizontally all the items with the header should scroll together and the first & last item of each row should stick at their position.

I can achieve all but the table is either vertically scrollable or horizontally scrollable.

I don't want to use ref because with ref scrolling is not synchronised. Below I am sharing a video of how it's currently working. The only problem is horizontal scrolling which is not synchronised.

Scrolling Table In React-Native

In a react-native, I have to create a table View which should match the following conditions:

  1. The first row should be the header where the First & last Items should be sticky and items in the centre can be horizontally scrollable, also, the header should be sticky for vertical scroll.
  2. From the second row onwards we will have actual data where again, the First & last Items should be sticky and items in the centre can be horizontally scrollable.
  3. Other than the header table, it should be vertically scrollable including the first & last item of each row, also when scrolling vertically it should look like the complete row is scrolling together.
  4. Also when the user scrolls horizontally all the items with the header should scroll together and the first & last item of each row should stick at their position.

I can achieve all but the table is either vertically scrollable or horizontally scrollable.

I don't want to use ref because with ref scrolling is not synchronised. Below I am sharing a video of how it's currently working. The only problem is horizontal scrolling which is not synchronised.

Scrolling Table In React-Native

Share Improve this question asked Nov 20, 2024 at 11:38 Sandeep MishraSandeep Mishra 6842 gold badges9 silver badges21 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Here's how you can go about it

divide layout:

  • first row would be its own component with a scroll view, and fixed label
  • remaining data in a flatlist, that renders custom data with fixed dates

synchronise list scrolls to enable body scrolling

here's a link to a working example - https://snack.expo.dev/gJJCLlFS0dghuUv6XUlx7

发布评论

评论列表(0)

  1. 暂无评论