You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I did notice something that I'm not totally on board with. in the TableSortable.html file, you are iterating through the rows like this:
<tr*ngFor="#object of data | orderBy : convertSorting()"><td*ngFor="#key of object | mapToIterable; #i = index" [innerHtml]="object[columns[i].variable] | format : columns[i].filter"></td></tr>
So you're iterating over the rows (data) and calling the variable key on columns to get the value with object[columns[i].variable]. The reason I have issues with this is that if you pass the tablesortable component rows that include other keys that you do not plan to display in the table, you get undefined errors on columns[i].variable because you don't want to see certain row values, you didn't add them to the columns array and because you are iterating over the rows, it errors.
What I'd like to propose is iterating over the columns themselves - so that you're only ever calling for what actually has been defined to display from the rows. Something like this:
<tr*ngFor="#object of data | orderBy : convertSorting()"><td*ngFor="#column of columns; #i = index" [innerHtml]="object[column.variable] | format : column.filter"></td></tr>
This way, we don't need to handle / reduce / process the rows array any further after getting it from the backend / API, and only the items placed in columns will be shown.
What do you think?
The text was updated successfully, but these errors were encountered:
This is much cleaner, and I definitely agree. It removes the need to map the key/value pairs of an arbitrary object using that mapToIterable pipe, since columns is already a defined, iterable type.
We won't need the index anymore like so:
<tr*ngFor="#object of data | orderBy : convertSorting()"><td*ngFor="#column of columns" [innerHtml]="object[column.variable] | format : column.filter"></td></tr>
Feel free to make a pull request if you don't want to wait. If not, this will be added to the next release.
Will close this once, this is fix is live in master.
Hey there, great package!
I did notice something that I'm not totally on board with. in the
TableSortable.html
file, you are iterating through the rows like this:So you're iterating over the rows (
data
) and calling thevariable
key on columns to get the value withobject[columns[i].variable]
. The reason I have issues with this is that if you pass the tablesortable component rows that include other keys that you do not plan to display in the table, you get undefined errors oncolumns[i].variable
because you don't want to see certain row values, you didn't add them to thecolumns
array and because you are iterating over the rows, it errors.What I'd like to propose is iterating over the columns themselves - so that you're only ever calling for what actually has been defined to display from the
rows
. Something like this:This way, we don't need to handle / reduce / process the
rows
array any further after getting it from the backend / API, and only the items placed incolumns
will be shown.What do you think?
The text was updated successfully, but these errors were encountered: