@@ -24,10 +24,10 @@ public Task OnLoadAsync(Kernel kernel)
24
24
25
25
public static void RegisterDataFrame ( )
26
26
{
27
- Formatter < DataFrame > . Register ( ( df , writer ) =>
27
+ Formatter . Register < DataFrame > ( ( df , writer ) =>
28
28
{
29
- const int MAX = 10000 ;
30
- const int SIZE = 10 ;
29
+ const int maxRowCount = 10000 ;
30
+ const int rowsPerPage = 25 ;
31
31
32
32
var uniqueId = DateTime . Now . Ticks ;
33
33
@@ -37,15 +37,15 @@ public static void RegisterDataFrame()
37
37
} ;
38
38
header . AddRange ( df . Columns . Select ( c => ( IHtmlContent ) th ( c . Name ) ) ) ;
39
39
40
- if ( df . Rows . Count > SIZE )
40
+ if ( df . Rows . Count > rowsPerPage )
41
41
{
42
- var maxMessage = df . Rows . Count > MAX ? $ " (showing a max of { MAX } rows)" : string . Empty ;
42
+ var maxMessage = df . Rows . Count > maxRowCount ? $ " (showing a max of { maxRowCount } rows)" : string . Empty ;
43
43
var title = h3 [ style : "text-align: center;" ] ( $ "DataFrame - { df . Rows . Count } rows { maxMessage } ") ;
44
44
45
45
// table body
46
- var maxRows = Math . Min ( MAX , df . Rows . Count ) ;
46
+ var rowCount = Math . Min ( maxRowCount , df . Rows . Count ) ;
47
47
var rows = new List < List < IHtmlContent > > ( ) ;
48
- for ( var index = 0 ; index < maxRows ; index ++ )
48
+ for ( var index = 0 ; index < rowCount ; index ++ )
49
49
{
50
50
var cells = new List < IHtmlContent >
51
51
{
@@ -58,29 +58,29 @@ public static void RegisterDataFrame()
58
58
rows . Add ( cells ) ;
59
59
}
60
60
61
- //navigator
61
+ //navigator
62
62
var footer = new List < IHtmlContent > ( ) ;
63
63
BuildHideRowsScript ( uniqueId ) ;
64
64
65
- var paginateScriptFirst = BuildHideRowsScript ( uniqueId ) + GotoPageIndex ( uniqueId , 0 ) + BuildPageScript ( uniqueId , SIZE ) ;
65
+ var paginateScriptFirst = BuildHideRowsScript ( uniqueId ) + GotoPageIndex ( uniqueId , 0 ) + BuildPageScript ( uniqueId , rowsPerPage ) ;
66
66
footer . Add ( button [ style : "margin: 2px;" , onclick : paginateScriptFirst ] ( "⏮" ) ) ;
67
67
68
- var paginateScriptPrevTen = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , - 10 , ( maxRows - 1 ) / SIZE ) + BuildPageScript ( uniqueId , SIZE ) ;
68
+ var paginateScriptPrevTen = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , - 10 , ( rowCount - 1 ) / rowsPerPage ) + BuildPageScript ( uniqueId , rowsPerPage ) ;
69
69
footer . Add ( button [ style : "margin: 2px;" , onclick : paginateScriptPrevTen ] ( "⏪" ) ) ;
70
70
71
- var paginateScriptPrev = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , - 1 , ( maxRows - 1 ) / SIZE ) + BuildPageScript ( uniqueId , SIZE ) ;
71
+ var paginateScriptPrev = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , - 1 , ( rowCount - 1 ) / rowsPerPage ) + BuildPageScript ( uniqueId , rowsPerPage ) ;
72
72
footer . Add ( button [ style : "margin: 2px;" , onclick : paginateScriptPrev ] ( "◀️" ) ) ;
73
73
74
74
footer . Add ( b [ style : "margin: 2px;" ] ( "Page" ) ) ;
75
75
footer . Add ( b [ id : $ "page_{ uniqueId } ", style : "margin: 2px;" ] ( "1" ) ) ;
76
76
77
- var paginateScriptNext = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , 1 , ( maxRows - 1 ) / SIZE ) + BuildPageScript ( uniqueId , SIZE ) ;
77
+ var paginateScriptNext = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , 1 , ( rowCount - 1 ) / rowsPerPage ) + BuildPageScript ( uniqueId , rowsPerPage ) ;
78
78
footer . Add ( button [ style : "margin: 2px;" , onclick : paginateScriptNext ] ( "▶️" ) ) ;
79
79
80
- var paginateScriptNextTen = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , 10 , ( maxRows - 1 ) / SIZE ) + BuildPageScript ( uniqueId , SIZE ) ;
80
+ var paginateScriptNextTen = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , 10 , ( rowCount - 1 ) / rowsPerPage ) + BuildPageScript ( uniqueId , rowsPerPage ) ;
81
81
footer . Add ( button [ style : "margin: 2px;" , onclick : paginateScriptNextTen ] ( "⏩" ) ) ;
82
82
83
- var paginateScriptLast = BuildHideRowsScript ( uniqueId ) + GotoPageIndex ( uniqueId , ( maxRows - 1 ) / SIZE ) + BuildPageScript ( uniqueId , SIZE ) ;
83
+ var paginateScriptLast = BuildHideRowsScript ( uniqueId ) + GotoPageIndex ( uniqueId , ( rowCount - 1 ) / rowsPerPage ) + BuildPageScript ( uniqueId , rowsPerPage ) ;
84
84
footer . Add ( button [ style : "margin: 2px;" , onclick : paginateScriptLast ] ( "⏭️" ) ) ;
85
85
86
86
//table
@@ -93,7 +93,7 @@ public static void RegisterDataFrame()
93
93
writer . Write ( t ) ;
94
94
95
95
//show first page
96
- writer . Write ( $ "<script>{ BuildPageScript ( uniqueId , SIZE ) } </script>") ;
96
+ writer . Write ( $ "<script>{ BuildPageScript ( uniqueId , rowsPerPage ) } </script>") ;
97
97
}
98
98
else
99
99
{
0 commit comments