Git Product home page Git Product logo

Comments (8)

maxim-saplin avatar maxim-saplin commented on August 12, 2024 3

There's an early version of DataTable2 which allows setting N fixed left columns and M top rows. It can be found in the following branch: https://github.com/maxim-saplin/data_table_2/tree/sticky-row-col

from data_table_2.

nxr836 avatar nxr836 commented on August 12, 2024

For PaginatedDataTable2.

from data_table_2.

maxim-saplin avatar maxim-saplin commented on August 12, 2024

There're no guys, it is just me) Do you maen making them always visible just like header row.

from data_table_2.

nxr836 avatar nxr836 commented on August 12, 2024

There're no guys, it is just me) Do you mean making them always visible just like header row.

lol.

Yeah, if some columns are always visible, for instance, the serial # and timestamp, that will be quite convenient for table users.

from data_table_2.

maxim-saplin avatar maxim-saplin commented on August 12, 2024

It took some time to get this request) Reflected on the matter, though don't plan to approach that feature any time soon - that would require a solid overhaul of widgets.

Will keep that issue open, might be worked on some time in the future.

from data_table_2.

berkanaslan avatar berkanaslan commented on August 12, 2024

You can have this view with two DataTable2 Widgets wrapped with Row. (One of them includes fixed columns and rows the other one includes other data.) But both cannot be vertical scroll at the same time. A wrapper like ListView is needed. This time, the fixed row property is lost. I don't know, maybe you have a solution/idea for scroll.

from data_table_2.

daixianceng avatar daixianceng commented on August 12, 2024

Use Row to split the screen in half, nest DataTable2 on the left and right, and then use ScrollNotification to sync the scroll offset.

sync_scroll_controller_manager.dart

import 'package:flutter/material.dart';

class SyncScrollControllerManager {
  final List<ScrollController> _registeredScrollControllers = [];
  ScrollController? _scrollingController;
  bool _scrollingActive = false;

  void registerScrollController(ScrollController controller) {
    _registeredScrollControllers.add(controller);
  }

  void unregisterScrollController(ScrollController controller) {
    _registeredScrollControllers.remove(controller);
  }

  void processNotification(
      ScrollNotification notification, ScrollController sender) {
    if (notification is ScrollStartNotification && !_scrollingActive) {
      _scrollingController = sender;
      _scrollingActive = true;
      return;
    }

    if (identical(sender, _scrollingController) && _scrollingActive) {
      if (notification is ScrollEndNotification) {
        _scrollingController = null;
        _scrollingActive = false;
        return;
      }

      if (notification is ScrollUpdateNotification) {
        _registeredScrollControllers.forEach(
          (controller) {
            if (!identical(_scrollingController, controller)) {
              if (controller.hasClients) {
                controller.jumpTo(_scrollingController?.offset ?? 0);
              }
            }
          },
        );
        return;
      }
    }
  }
}

home.dart

import 'package:data_table_2/data_table_2.dart';
import 'package:flutter/material.dart';
import './sync_scroll_controller_manager.dart';

class Home extends StatelessWidget {
  Home({Key? key}) : super(key: key);

  final ScrollController _leftScrollController = ScrollController();
  final ScrollController _rightScrollController = ScrollController();
  final SyncScrollControllerManager _syncScroller =
      SyncScrollControllerManager();

  @override
  Widget build(BuildContext context) {
    _syncScroller.registerScrollController(_leftScrollController);
    _syncScroller.registerScrollController(_rightScrollController);
    return Scaffold(
        appBar: AppBar(),
        body: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            SizedBox( // first culumn
              width: 100,
              child: NotificationListener<ScrollNotification>(
                child: DataTable2(
                  scrollController: _leftScrollController,
                  // ... more properties
                ),
                onNotification: (ScrollNotification scrollInfo) { // listening scroll event
                  _syncScroller.processNotification(
                      scrollInfo, _leftScrollController);
                  return false;
                },
              ),
            ),
            Expanded( // second culumn
              child: NotificationListener<ScrollNotification>(
                child: DataTable2(
                  scrollController: _rightScrollController,
                  // ... more properties
                ),
                onNotification: (ScrollNotification scrollInfo) { // listening scroll event
                  _syncScroller.processNotification(
                      scrollInfo, _rightScrollController);
                  return false;
                },
              ),
            )
          ],
        ));
  }
}

from data_table_2.

maxim-saplin avatar maxim-saplin commented on August 12, 2024

Pushed to pub.dev

from data_table_2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.