Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aggrid
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
aggrid
Commits
000fb7fd
Commit
000fb7fd
authored
3 years ago
by
Mike Feranda
Committed by
Mike Feranda
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3217744
by mferanda: Add viewHide setting for headers/columns
parent
e6b16db2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
css/aggrid.widget.css
+6
-0
6 additions, 0 deletions
css/aggrid.widget.css
src/AggridConfigHelpers.php
+53
-53
53 additions, 53 deletions
src/AggridConfigHelpers.php
src/Plugin/Field/FieldFormatter/HtmlFormatterType.php
+36
-8
36 additions, 8 deletions
src/Plugin/Field/FieldFormatter/HtmlFormatterType.php
with
95 additions
and
61 deletions
css/aggrid.widget.css
+
6
−
0
View file @
000fb7fd
...
...
@@ -92,6 +92,12 @@ div.ag-root .aggrid-cell-hidden {
visibility
:
hidden
;
}
table
.aggrid-html-widget
.aggrid-htmlcell-viewhide
{
display
:
none
;
visibility
:
hidden
;
width
:
0
;
}
div
.ag-root
.aggrid-cell-indent
,
table
.aggrid-html-widget
.aggrid-htmlcell-indent
{
padding-left
:
15px
;
...
...
This diff is collapsed.
Click to expand it.
src/AggridConfigHelpers.php
+
53
−
53
View file @
000fb7fd
...
...
@@ -40,12 +40,12 @@ class AggridConfigHelpers {
return
$aggridDefault
;
}
public
function
getHeaders
(
$columnDefs
)
{
public
function
getHeaders
(
$columnDefs
,
$dataHeaderSettings
=
null
)
{
$getHeaders
=
[];
$columns
=
[];
$
columnField
s
=
""
;
$
header
s
=
[]
;
// Build table.
$rowIndex
=
0
;
...
...
@@ -55,72 +55,72 @@ class AggridConfigHelpers {
$rowIndex
=
$rowIndex
>
1
?
$rowIndex
:
1
;
$colIndex
++
;
$columns
[
1
][
$colIndex
][
$colIndex
][
$column
->
headerName
]
=
[];
$columns
[
1
][
$colIndex
][
$colIndex
][
$column
->
headerName
][
'headerName'
]
=
$column
->
headerName
;
$columns
[
1
][
$colIndex
][
$colIndex
][
$column
->
headerName
][
'field'
]
=
isset
(
$column
->
field
)
?
$column
->
field
:
NULL
;
$columns
[
1
][
$colIndex
][
$colIndex
][
$column
->
headerName
][
'width'
]
=
isset
(
$column
->
width
)
?
$column
->
width
:
NULL
;
$columns
[
1
][
$colIndex
][
$colIndex
][
$column
->
headerName
][
'minWidth'
]
=
isset
(
$column
->
minWidth
)
?
$column
->
minWidth
:
NULL
;
// Set the field if available.
if
(
isset
(
$column
->
field
))
{
$columnFields
.
=
$column
->
field
.
","
;
}
$columns
[
1
][
$colIndex
][
$colIndex
]
=
[];
$columns
[
1
][
$colIndex
][
$colIndex
][
'headerName'
]
=
$column
->
headerName
;
$columns
[
1
][
$colIndex
][
$colIndex
][
'headerNameFull'
]
=
$column
->
headerName
;
$columns
[
1
][
$colIndex
][
$colIndex
][
'field'
]
=
isset
(
$column
->
field
)
?
$column
->
field
:
NULL
;
$columns
[
1
][
$colIndex
][
$colIndex
][
'width'
]
=
isset
(
$column
->
width
)
?
$column
->
width
:
NULL
;
$columns
[
1
][
$colIndex
][
$colIndex
][
'minWidth'
]
=
isset
(
$column
->
minWidth
)
?
$column
->
minWidth
:
NULL
;
$columns
[
1
][
$colIndex
][
$colIndex
][
'viewHide'
]
=
isset
(
$column
->
viewHide
)
?
$column
->
viewHide
:
false
;
// If children, then dive down for headers, otherwise establish column.
if
(
isset
(
$column
->
children
))
{
$columns
[
1
][
$colIndex
][
$colIndex
][
$column
->
headerName
][
'colspan'
]
=
count
(
$column
->
children
);
$colCount
=
count
(
$column
->
children
);
$columns
[
1
][
$colIndex
][
$colIndex
][
'colspan'
]
=
$colCount
;
$count2
=
0
;
foreach
(
$column
->
children
as
$child
)
{
// If column is hidden on view, reduce previous colspan by one
if
(
isset
(
$child
->
viewHide
)
&&
$child
->
viewHide
)
{
$colCount
=
$columns
[
1
][
$colIndex
][
$colIndex
][
'colspan'
];
$columns
[
1
][
$colIndex
][
$colIndex
][
'colspan'
]
=
$colCount
-
1
;
}
$rowIndex
=
$rowIndex
>
2
?
$rowIndex
:
2
;
$count2
++
;
$columns
[
2
][
$colIndex
][
$count2
][
$column
->
headerName
.
' - '
.
$child
->
headerName
]
=
[];
$columns
[
2
][
$colIndex
][
$count2
][
$column
->
headerName
.
' - '
.
$child
->
headerName
][
'headerName'
]
=
$child
->
headerName
;
$columns
[
2
][
$colIndex
][
$count2
][
$column
->
headerName
.
' - '
.
$child
->
headerName
][
'field'
]
=
isset
(
$child
->
field
)
?
$child
->
field
:
NULL
;
$columns
[
2
][
$colIndex
][
$count2
][
$column
->
headerName
.
' - '
.
$child
->
headerName
][
'width'
]
=
isset
(
$child
->
width
)
?
$child
->
width
:
NULL
;
$columns
[
2
][
$colIndex
][
$count2
][
$column
->
headerName
.
' - '
.
$child
->
headerName
][
'minWidth'
]
=
isset
(
$child
->
minWidth
)
?
$child
->
minWidth
:
NULL
;
$columns
[
2
][
$colIndex
][
$count2
]
=
[];
$columns
[
2
][
$colIndex
][
$count2
][
'headerName'
]
=
$child
->
headerName
;
$columns
[
2
][
$colIndex
][
$count2
][
'headerNameFull'
]
=
$column
->
headerName
.
' - '
.
$child
->
headerName
;
$columns
[
2
][
$colIndex
][
$count2
][
'field'
]
=
isset
(
$child
->
field
)
?
$child
->
field
:
NULL
;
$columns
[
2
][
$colIndex
][
$count2
][
'width'
]
=
isset
(
$child
->
width
)
?
$child
->
width
:
NULL
;
$columns
[
2
][
$colIndex
][
$count2
][
'minWidth'
]
=
isset
(
$child
->
minWidth
)
?
$child
->
minWidth
:
NULL
;
$columns
[
2
][
$colIndex
][
$count2
][
'viewHide'
]
=
isset
(
$child
->
viewHide
)
?
$child
->
viewHide
:
false
;
// if the viewhide is true viewHide as true for this child
if
(
$columns
[
1
][
$colIndex
][
$colIndex
][
'viewHide'
])
{
$columns
[
2
][
$colIndex
][
$count2
][
'viewHide'
]
=
true
;
}
// Set the field if available.
if
(
isset
(
$child
->
field
))
{
$columnFields
.
=
$child
->
field
.
","
;
$headers
[]
=
$child
->
field
;
$columns
[
0
][
$child
->
field
]
=
[];
$columns
[
0
][
$child
->
field
][
'viewHide'
]
=
$columns
[
2
][
$colIndex
][
$count2
][
'viewHide'
];
}
if
(
isset
(
$child
->
children
))
{
$columns
[
2
][
$colIndex
][
$count2
][
$column
->
headerName
.
' - '
.
$column
->
headerName
][
'colspan'
]
=
count
(
$child
->
children
);
$count3
=
0
;
foreach
(
$child
->
children
as
$subchild
)
{
$rowIndex
=
$rowIndex
>
3
?
$rowIndex
:
3
;
$count3
++
;
$columns
[
3
][
$colIndex
][
$count3
][
$column
->
headerName
.
' - '
.
$child
->
headerName
.
' - '
.
$subchild
->
headerName
]
=
[];
$columns
[
3
][
$colIndex
][
$count3
][
$column
->
headerName
.
' - '
.
$child
->
headerName
.
' - '
.
$subchild
->
headerName
][
'headerName'
]
=
$subchild
->
headerName
;
$columns
[
3
][
$colIndex
][
$count3
][
$column
->
headerName
.
' - '
.
$child
->
headerName
.
' - '
.
$subchild
->
headerName
][
'field'
]
=
isset
(
$subchild
->
field
)
?
$subchild
->
field
:
NULL
;
$columns
[
3
][
$colIndex
][
$count3
][
$column
->
headerName
.
' - '
.
$child
->
headerName
.
' - '
.
$subchild
->
headerName
][
'colspan'
]
=
1
;
$columns
[
3
][
$colIndex
][
$count3
][
$column
->
headerName
.
' - '
.
$child
->
headerName
.
' - '
.
$subchild
->
headerName
][
'width'
]
=
isset
(
$subchild
->
width
)
?
$subchild
->
width
:
NULL
;
$columns
[
3
][
$colIndex
][
$count3
][
$column
->
headerName
.
' - '
.
$child
->
headerName
.
' - '
.
$subchild
->
headerName
][
'minWidth'
]
=
isset
(
$subchild
->
minWidth
)
?
$subchild
->
minWidth
:
NULL
;
// Set the field if available.
if
(
isset
(
$subchild
->
field
))
{
$columnFields
.
=
$subchild
->
field
.
","
;
}
}
}
else
{
// Just one for colspan.
$columns
[
2
][
$colIndex
][
$count2
][
$column
->
headerName
.
' - '
.
$child
->
headerName
][
'colspan'
]
=
1
;
}
// Just one for colspan.
$columns
[
2
][
$colIndex
][
$count2
][
'colspan'
]
=
1
;
}
}
else
{
// Just one for colspan.
$columns
[
1
][
$colIndex
][
$colIndex
][
$column
->
headerName
][
'colspan'
]
=
1
;
$columns
[
1
][
$colIndex
][
$colIndex
][
'colspan'
]
=
1
;
}
// If the parent column colspan is now 0, then default viewHide to true (all children are hidden)
if
(
$columns
[
1
][
$colIndex
][
$colIndex
][
'colspan'
]
<=
0
)
{
$columns
[
1
][
$colIndex
][
$colIndex
][
'viewHide'
]
=
true
;
}
}
// Put columnFields to headers, trim comma, and put to array.
$headers
=
$columnFields
;
$headers
=
substr
(
$headers
,
0
,
strlen
(
$headers
)
-
1
);
$headers
=
str_getcsv
(
$headers
);
// Set the field if available.
if
(
isset
(
$column
->
field
))
{
$headers
[]
=
$column
->
field
;
$columns
[
0
][
$column
->
field
]
=
[];
$columns
[
0
][
$column
->
field
][
'viewHide'
]
=
$columns
[
1
][
$colIndex
][
$colIndex
][
'viewHide'
];
}
}
// Set return
$getHeaders
[
'rowIndex'
]
=
$rowIndex
;
...
...
@@ -145,11 +145,11 @@ class AggridConfigHelpers {
if
(
isset
(
$aggridRowSettings
[
$rowPrefix
.
$i
][
'rowDefault'
]))
{
$rowSettings
[
$i
][
$field
]
=
$rowSettings
[
$i
][
$field
]
+
$aggridRowSettings
[
$rowPrefix
.
$i
][
'rowDefault'
];
}
if
(
isset
(
$aggridRowSettings
[
'default'
][
$field
]))
{
$rowSettings
[
$i
][
$field
]
=
$rowSettings
[
$i
][
$field
]
+
$aggridRowSettings
[
'default'
][
$field
];
if
(
isset
(
$aggridRowSettings
[
$rowPrefix
.
'default'
][
$field
]))
{
$rowSettings
[
$i
][
$field
]
=
$rowSettings
[
$i
][
$field
]
+
$aggridRowSettings
[
$rowPrefix
.
'default'
][
$field
];
}
if
(
isset
(
$aggridRowSettings
[
'default'
][
'rowDefault'
]))
{
$rowSettings
[
$i
][
$field
]
=
$rowSettings
[
$i
][
$field
]
+
$aggridRowSettings
[
'default'
][
'rowDefault'
];
if
(
isset
(
$aggridRowSettings
[
$rowPrefix
.
'default'
][
'rowDefault'
]))
{
$rowSettings
[
$i
][
$field
]
=
$rowSettings
[
$i
][
$field
]
+
$aggridRowSettings
[
$rowPrefix
.
'default'
][
'rowDefault'
];
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/Plugin/Field/FieldFormatter/HtmlFormatterType.php
+
36
−
8
View file @
000fb7fd
...
...
@@ -80,7 +80,7 @@ class HtmlFormatterType extends FormatterBase {
/**
* {@inheritdoc}
*/
public
function
createAggridRowData
(
$rowSettings
,
$headers
,
$rowData
)
{
public
function
createAggridRowData
(
$rowSettings
,
$columns
,
$headers
,
$rowData
)
{
$aggridSuppression
=
new
AggridSuppression
();
...
...
@@ -172,6 +172,12 @@ class HtmlFormatterType extends FormatterBase {
}
else
{
$cellScope
=
''
;
}
// Check settings
if
(
isset
(
$columns
[
0
][
$field
])
&&
$columns
[
0
][
$field
][
'viewHide'
])
{
$cellClass
=
$cellClass
.
' aggrid-htmlcell-viewhide'
;
}
// Check if field/cell exists. If not, blank it as default.
if
(
isset
(
$rowData
[
$i
]
->
$field
))
{
...
...
@@ -257,28 +263,50 @@ class HtmlFormatterType extends FormatterBase {
$headers
=
$getHeaders
[
'headers'
];
$columns
=
$getHeaders
[
'columns'
];
// Data Header Settings.
$dataHeaderSettings
[][][]
=
""
;
$dataHeaderSettings
=
$aggridConfigHelpers
->
getRowSettings
(
$aggridRowSettings
,
$headers
,
$columns
,
'dh-'
);
// Run the headers again for colSpan
// Get header information
$getHeaders
=
$aggridConfigHelpers
->
getHeaders
(
$aggridDefault
[
'default'
]
->
columnDefs
,
$dataHeaderSettings
);
// Set the variables from header information
$headers
=
$getHeaders
[
'headers'
];
$columns
=
$getHeaders
[
'columns'
];
// Build table.
$table_render
=
''
;
$table_render
.
=
'<table id="'
.
$item_id
.
'-table" class="aggrid-html-widget"><thead>'
;
// Get the header rows.
for
(
$y
=
1
;
$y
<=
$rowIndex
;
$y
++
)
{
// Each header row and each column cell with spanning.
$table_render
.
=
'<tr>'
;
for
(
$x
=
1
;
$x
<=
$colIndex
;
$x
++
)
{
if
(
!
array_key_exists
(
$x
,
$columns
[
$y
]))
{
$table_render
.
=
'<th id="'
.
$
x
.
'"></th>'
;
$table_render
.
=
'<th id="'
.
$item_id
.
'-h'
.
$
y
.
'c'
.
$x
.
'"></th>'
;
}
else
{
foreach
(
$columns
[
$y
][
$x
]
as
$count
=>
$value
)
{
foreach
(
$columns
[
$y
][
$x
][
$count
]
as
$column
=>
$value
)
{
$table_render
.
=
'<th scope="col" id="'
.
$x
.
'" colspan="'
.
$columns
[
$y
][
$x
][
$count
][
$column
][
'colspan'
]
.
'" data-width="'
.
$columns
[
$y
][
$x
][
$count
][
$column
][
'width'
]
.
'" data-minWidth="'
.
$columns
[
$y
][
$x
][
$count
][
$column
][
'minWidth'
]
.
'">'
.
$columns
[
$y
][
$x
][
$count
][
$column
][
'headerName'
]
.
'</th>'
;
// Set variables for columns
$colClass
=
[];
$field
=
$columns
[
$y
][
$x
][
$count
][
'field'
];
// Check settings
if
(
isset
(
$columns
[
0
][
$field
])
&&
$columns
[
0
][
$field
][
'viewHide'
])
{
$colClass
[]
=
'aggrid-htmlcell-viewhide'
;
}
// Render the header
$table_render
.
=
'<th scope="col" id="'
.
$item_id
.
'-h'
.
$y
.
'c'
.
$x
.
'" class="'
.
implode
(
' '
,
$colClass
)
.
'" colspan="'
.
$columns
[
$y
][
$x
][
$count
][
'colspan'
]
.
'" data-width="'
.
$columns
[
$y
][
$x
][
$count
][
'width'
]
.
'" data-minWidth="'
.
$columns
[
$y
][
$x
][
$count
][
'minWidth'
]
.
'">'
.
$columns
[
$y
][
$x
][
$count
][
'headerName'
]
.
'</th>'
;
}
}
}
$table_render
.
=
'</tr>'
;
}
// Close up the headers and start on data rows.
$table_render
.
=
'</thead><tbody>'
;
...
...
@@ -287,13 +315,13 @@ class HtmlFormatterType extends FormatterBase {
$pinnedTopRowSettings
=
$aggridConfigHelpers
->
getRowSettings
(
$aggridRowSettings
,
$headers
,
$pinnedTopRowData
,
't-'
);
// Pinned Top Rows.
$table_render
.
=
$this
->
createAggridRowData
(
$pinnedTopRowSettings
,
$headers
,
$pinnedTopRowData
);
$table_render
.
=
$this
->
createAggridRowData
(
$pinnedTopRowSettings
,
$columns
,
$headers
,
$pinnedTopRowData
);
// (Data) Row Settings.
$rowSettings
=
$aggridConfigHelpers
->
getRowSettings
(
$aggridRowSettings
,
$headers
,
$rowData
,
''
);
// Data rows.
$table_render
.
=
$this
->
createAggridRowData
(
$rowSettings
,
$headers
,
$rowData
);
$table_render
.
=
$this
->
createAggridRowData
(
$rowSettings
,
$columns
,
$headers
,
$rowData
);
// Set the row suppression from after the actual rowData is run
$rowSuppression
=
$this
->
rowSuppression
;
...
...
@@ -301,7 +329,7 @@ class HtmlFormatterType extends FormatterBase {
$pinnedBottomRowSettings
=
$aggridConfigHelpers
->
getRowSettings
(
$aggridRowSettings
,
$headers
,
$pinnedBottomRowData
,
'b-'
);
// Pinned Bottom Rows.
$table_render
.
=
$this
->
createAggridRowData
(
$pinnedBottomRowSettings
,
$headers
,
$pinnedBottomRowData
);
$table_render
.
=
$this
->
createAggridRowData
(
$pinnedBottomRowSettings
,
$columns
,
$headers
,
$pinnedBottomRowData
);
// Close up the table.
$table_render
.
=
'</tbody></table>'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment