I am trying to define an Angular Material table with approx 24 columns and they are not uniform in behavior. Some columns just display text, others may have controls. I want to try and keep it as dynamic as possible and not have them all defined in the HTML file.
I have created an object to define a column object and create the columns dynamically:
<ng-container *ngFor="let column of columnDefinitions" [matColumnDef]="column.columnName">
<th mat-header-cell
*matHeaderCellDef
mat-sort-header
[disabled]="!column.sortable"> {{ column.label }} </th>
<td mat-cell *matCellDef="let row"
[ngClass]="getClasses(row, column)"> {{ getColumnContentFor(row, column.columnPath) }} </td>
</ng-container>
Some of the questions I have are around how to best add functionality based on the type of column I need:
I want to add a sticky column just to the first couple of columns
Ideally even the [ngClass] would like it only for certain columns so it doesn't have to evaluate this function for every column.
If some columns have a custom control how can I add a custom template
Any examples you may suggest would be extremely helpful.
You can do this by adding the index to ngFor, like this: *ngFor="let column of columnDefinitions; let i = index". Then, you can conditionally add the sticky position by adding this to the th cell: [style.position]="i < 2 ? 'sticky' : null" (null value means that the style won't be added).
EDIT: You also need to change the matHeaderRowDef to *matHeaderRowDef="columnsToDisplay; sticky: true"
While you can use something like ngSwitch for that, I don't think it's worth the effort. You can, however, make sure you return null as early as possible for classes that don't need it.
Inside the td element, you can use ngSwitch, as described here. You can use the column index, for example.
Related
I am trying to customize the columnsMenuTab display in ag-grid to hide certain group header rows from being shown. We have a column group hierarchy that looks something like:
Name
Type Name
Formula
Column Name
We'd like to hide the Formulas from being displayed inside the columnsMenuTab so that when the user is toggling the column visibility they don't see the formulas but they can still see the column name. The end result would be something like:
Name
Type Name
Column Name
Looking through the documentation (https://www.ag-grid.com/javascript-grid-column-menu/) I was not able to find a way to achieve this customization.
We are using ag-grid-react (enterprise) 21.0.1
Thanks.
05/18 Edit: Added some clarification as to the end result.
You can use suppressColumnsToolPanel: true for the column you dont want to show up in columnsMenuTab as well as the tool panel that shows up on the right.
This works for column or column group in the hierarchy and should work for Formula column in your case.
As per docs-
suppressColumnsToolPanel Set to true if you do not want this column or group to appear in the Columns Tool Panel. Default: false
Still works in #ag-grid-community/core#^28.1.1 #ag-grid-enterprise/column-tool-panel#^28.1.1
I set suppressColumnsToolPanel: true on one of the columns and this column does not appear in the column menu > column selection tab anymore.
I am using tablesorter with child rows. My table has many many child rows per parent row. All child rows have same number of columns as that of parent.
I have filters implemented, with which I can search both parent and child. When I do a search in the filter box for a column, I notice that all filter matches from all columns a child row are also reported. The intend in my application is to report matches for a specific column (same column of filter box) regardless of whether it is a parent or a child.
Has anybody came across this before ?
For example, look at this site
http://mottie.github.io/tablesorter/docs/example-child-rows-filtered.html
If we search for "Colorado" in the "Date" column filter box, one entry will still show up, which has the string "Colorado" in some some unrelated column in the child row.
I have the same problem. The way we overcame was basically to make childrow have its own specific columns and then add external filters only on those columns. Then we had to hide the filters in the header for columns with child column data. Not sure if this has been fixed.
<tr class="tablesorter-childRow">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>child column filter 1</td>
<td class="filter-match">Child column fiter 2</td>
<td class="filter-match">child column filter 3</td>
</tr>
I have some xml text to be inserted in the document as plain text. I directly inserted but it gives weird symbols. How can I avoid that?
XML I want to add:
\begin{tabular}{|c|}
<table>
<tr>
<td> Title and Logo</td>
</tr>
<tr>
<td> left Column </td>
<td> main table </td>
</tr>
</table>
\end{tabular}
And the output is like :
¡table¿ ¡tr¿ ¡td¿ Title and Logo¡/td¿ ¡/tr¿ ¡tr¿ ¡td¿ left Column ¡/td¿ ¡td¿ main table ¡/td¿ ¡/tr¿ ¡/table
Basically I want to add the HTML code in a tabular. How can I do that?
Have you tried the verbatim environment?
\begin{verbatim}
Your text here.
\end{verbatim}
Without knowing what your "weird symbols" are, it's difficult to suggest a solution to your problem.
Update: In order to embed a verbatim environment in a table cell, you need to change the column to a paragraph column (using either p, m, or b as the column specifier); e.g.
\begin{tabular}{|p{10cm}|}
\begin{verbatim}
Your text here.
\end{verbatim}
\end{tabular}
See Wikibooks for more information.
I have a default scaffolded view and in the list view, all my integer values are shown with digit grouping. (like 5,129)
I couldn't find a way to disable this behavior. I tried on both English and Turkish locale. I am not sure if it is used but the messages.properties file is all default values:
default.date.format=yyyy-MM-dd HH:mm:ss z
default.number.format=0
If I change the view and add g:formatNumber around the value such as
<g:formatNumber number="${fieldValue(bean: tagInstance, field: 'tag_id')}" type="number" groupingUsed="false" />
all that gets printed is 5 (for the number 5129)
Eliminating the fieldValue() call fixed it.
${tagInstance.tag_id}
prints the number without any formatting.
Have you tried this:
default.number.format=#
Note that the # will cause a value of 0 to not display. If you want it to display, you'll probably want:
default.number.format=#0
Hey. How can i have a variable in each tag to be an iterator (for example, first time run cycle takes value=1, second time value=2, and so on..
The status attribute is what you are looking for. See below:
<g:each collection=${books} var="abook" status="i">
${i}
</g:each>
if you call ${i} inside the each tag it will return the current iteration count.
Assuming the books collection contains 5 books, the output will be:
0
1
2
3
4