You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2021/12/16 18:16:11 UTC

[superset] branch sqllab/infinite updated (f4114f8 -> 3117bbf)

This is an automated email from the ASF dual-hosted git repository.

hugh pushed a change to branch sqllab/infinite
in repository https://gitbox.apache.org/repos/asf/superset.git.


    from f4114f8  semi working infinite callbacks
     new 5088c8f  save for now
     new 3117bbf  save

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../components/FilterableTable/FilterableTable.tsx | 117 ++++++++++-----------
 1 file changed, 57 insertions(+), 60 deletions(-)

[superset] 01/02: save for now

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch sqllab/infinite
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 5088c8f849c6fa3fcc3fa695fd2886c143ac56ec
Author: hughhhh <hu...@gmail.com>
AuthorDate: Wed Dec 15 15:20:47 2021 -0500

    save for now
---
 .../src/components/FilterableTable/FilterableTable.tsx   | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/superset-frontend/src/components/FilterableTable/FilterableTable.tsx b/superset-frontend/src/components/FilterableTable/FilterableTable.tsx
index d05e8c9..59796ab 100644
--- a/superset-frontend/src/components/FilterableTable/FilterableTable.tsx
+++ b/superset-frontend/src/components/FilterableTable/FilterableTable.tsx
@@ -156,6 +156,8 @@ export default class FilterableTable extends PureComponent<
     this.rowClassName = this.rowClassName.bind(this);
     this.sort = this.sort.bind(this);
     this._onSectionRendered = this._onSectionRendered.bind(this);
+    this._loadMoreRows = this._loadMoreRows.bind(this);
+    this._isRowLoaded = this._isRowLoaded.bind(this);
 
     // columns that have complex type and were expanded into sub columns
     this.complexColumns = props.orderedColumnKeys.reduce(
@@ -175,6 +177,7 @@ export default class FilterableTable extends PureComponent<
     this.state = {
       sortDirection: SortDirection.ASC,
       fitted: false,
+      rowIdx: 100,
     };
 
     this.container = React.createRef();
@@ -493,7 +496,7 @@ export default class FilterableTable extends PureComponent<
         <InfiniteLoader
           isRowLoaded={this._isRowLoaded}
           loadMoreRows={this._loadMoreRows}
-          rowCount={100}
+          rowCount={this.state.rowIdx}
           threshold={1}
         >
           {({ onRowsRendered, registerChild }) => {
@@ -507,7 +510,7 @@ export default class FilterableTable extends PureComponent<
                 // onScroll={onScroll}
                 overscanColumnCount={overscanColumnCount}
                 overscanRowCount={overscanRowCount}
-                rowCount={this.list.length}
+                rowCount={this.state.rowIdx}
                 rowHeight={rowHeight}
                 width={1000}
                 onSectionRendered={this._onSectionRendered}
@@ -560,16 +563,21 @@ export default class FilterableTable extends PureComponent<
   }
 
   _isRowLoaded({ index }) {
-    console.log(index);
-    return true;
+    const { rowIdx } = this.state;
+    console.log(rowIdx);
+    return index < rowIdx - 1; // this condition determins whether _loadMoreRows will be called
   }
 
   _loadMoreRows({ startIndex, stopIndex }) {
     console.log('in loadmore rows');
+    this.setState({ rowIdx: this.state.rowIdx + 1 });
     let done;
     return new Promise(resolve => (done = resolve));
   }
   _onSectionRendered({ rowStartIndex, rowStopIndex }) {
+    // console.log('rowStartIndex', rowStartIndex)
+    // console.log('rowStopIndex', rowStopIndex)
+
     this._onRowsRendered({
       startIndex: rowStartIndex,
       stopIndex: rowStopIndex,

[superset] 02/02: save

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch sqllab/infinite
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 3117bbf988c081969000fafcb33337050d492b55
Author: hughhhh <hu...@gmail.com>
AuthorDate: Thu Dec 16 13:14:45 2021 -0500

    save
---
 .../components/FilterableTable/FilterableTable.tsx | 109 +++++++++------------
 1 file changed, 49 insertions(+), 60 deletions(-)

diff --git a/superset-frontend/src/components/FilterableTable/FilterableTable.tsx b/superset-frontend/src/components/FilterableTable/FilterableTable.tsx
index 59796ab..2f0b576 100644
--- a/superset-frontend/src/components/FilterableTable/FilterableTable.tsx
+++ b/superset-frontend/src/components/FilterableTable/FilterableTable.tsx
@@ -156,8 +156,8 @@ export default class FilterableTable extends PureComponent<
     this.rowClassName = this.rowClassName.bind(this);
     this.sort = this.sort.bind(this);
     this._onSectionRendered = this._onSectionRendered.bind(this);
-    this._loadMoreRows = this._loadMoreRows.bind(this);
-    this._isRowLoaded = this._isRowLoaded.bind(this);
+    this.loadMoreRows = this.loadMoreRows.bind(this);
+    this.isRowLoaded = this.isRowLoaded.bind(this);
 
     // columns that have complex type and were expanded into sub columns
     this.complexColumns = props.orderedColumnKeys.reduce(
@@ -494,83 +494,72 @@ export default class FilterableTable extends PureComponent<
     return (
       <StyledFilterableTable>
         <InfiniteLoader
-          isRowLoaded={this._isRowLoaded}
-          loadMoreRows={this._loadMoreRows}
+          isRowLoaded={this.isRowLoaded}
+          loadMoreRows={this.loadMoreRows}
           rowCount={this.state.rowIdx}
           threshold={1}
         >
           {({ onRowsRendered, registerChild }) => {
             this._onRowsRendered = onRowsRendered;
             return (
-              <Grid
-                cellRenderer={this.renderGridCell}
-                columnCount={orderedColumnKeys.length}
-                columnWidth={getColumnWidth}
-                height={totalTableHeight - rowHeight}
-                // onScroll={onScroll}
-                overscanColumnCount={overscanColumnCount}
-                overscanRowCount={overscanRowCount}
-                rowCount={this.state.rowIdx}
-                rowHeight={rowHeight}
-                width={1000}
-                onSectionRendered={this._onSectionRendered}
-                ref={grid => {
-                  this._grid = grid;
-                  registerChild(grid);
-                }}
-              />
+              <ScrollSync>
+                {({ onScroll, scrollLeft }) => (
+                  <>
+                    <AutoSizer disableHeight>
+                      {({ width }) => (
+                        <div>
+                          <Grid
+                            cellRenderer={this.renderGridCellHeader}
+                            columnCount={orderedColumnKeys.length}
+                            columnWidth={getColumnWidth}
+                            height={rowHeight}
+                            rowCount={1}
+                            rowHeight={rowHeight}
+                            scrollLeft={scrollLeft}
+                            width={width}
+                            style={{ overflow: 'hidden' }}
+                          />
+                          <Grid
+                            cellRenderer={this.renderGridCell}
+                            columnCount={orderedColumnKeys.length}
+                            columnWidth={getColumnWidth}
+                            height={totalTableHeight - rowHeight}
+                            onScroll={onScroll}
+                            overscanColumnCount={overscanColumnCount}
+                            overscanRowCount={overscanRowCount}
+                            rowCount={this.state.rowIdx}
+                            rowHeight={rowHeight}
+                            width={1000}
+                            onSectionRendered={this._onSectionRendered}
+                            ref={grid => {
+                              this._grid = grid;
+                              registerChild(grid);
+                            }}
+                          />
+                        </div>
+                      )}
+                    </AutoSizer>
+                  </>
+                )}
+              </ScrollSync>
             );
           }}
         </InfiniteLoader>
-
-        <ScrollSync>
-          {({ onScroll, scrollLeft }) => (
-            <>
-              <AutoSizer disableHeight>
-                {({ width }) => (
-                  <div>
-                    <Grid
-                      cellRenderer={this.renderGridCellHeader}
-                      columnCount={orderedColumnKeys.length}
-                      columnWidth={getColumnWidth}
-                      height={rowHeight}
-                      rowCount={1}
-                      rowHeight={rowHeight}
-                      scrollLeft={scrollLeft}
-                      width={width}
-                      style={{ overflow: 'hidden' }}
-                    />
-                    <Grid
-                      cellRenderer={this.renderGridCell}
-                      columnCount={orderedColumnKeys.length}
-                      columnWidth={getColumnWidth}
-                      height={totalTableHeight - rowHeight}
-                      onScroll={onScroll}
-                      overscanColumnCount={overscanColumnCount}
-                      overscanRowCount={overscanRowCount}
-                      rowCount={this.list.length}
-                      rowHeight={rowHeight}
-                      width={width}
-                    />
-                  </div>
-                )}
-              </AutoSizer>
-            </>
-          )}
-        </ScrollSync>
       </StyledFilterableTable>
     );
   }
 
-  _isRowLoaded({ index }) {
+  isRowLoaded({ index }) {
     const { rowIdx } = this.state;
     console.log(rowIdx);
     return index < rowIdx - 1; // this condition determins whether _loadMoreRows will be called
   }
 
-  _loadMoreRows({ startIndex, stopIndex }) {
+  loadMoreRows({ startIndex, stopIndex }) {
     console.log('in loadmore rows');
-    this.setState({ rowIdx: this.state.rowIdx + 1 });
+    if (this.state.rowIdx + 1 < this.list.length) {
+      this.setState({ rowIdx: this.state.rowIdx + 1 });
+    }
     let done;
     return new Promise(resolve => (done = resolve));
   }