-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataTableFooterComponent: "Cannot read property 'toLocaleString' of undefined" #838
Comments
Seems from the error that selectedCount is null at some point - could it be that selectedCount is not initialized when the view part of the footer is rendered (on first load) and that is the source of the error. Then when selectedCount gets set, the binding kicks in and all is good. However, looking at what you posted, I would expect the footer to say something like "0 selected / 29 total". It is hard to tell without much of the code. Also possible that the error message is pointing at rowCount rather than selectedCount, or more likely both since you saw duplicates of the error. Either way, when the error is thrown, the property is null, likely prior to its initialization. Take a look at the lifecycle of selectedCount and rowCount to see when they get initialized. |
Have you solved it? I have the same problem and i don't know how to proceed EDIT: Before:
After:
|
I faced this issue, in our case it was my teammate mistake, she was initializing the rows as empty object not array |
I also faced this issue and figured out that the problem was that I was providing to DataTable an Object containing multiple Objects (rows) but I should provide an Array containing multiple Objects. More specifically, in my case the cause of problem was that the API providing the rows was filtering some results out of all DB results. This filtering caused that the array of rows didn't have sequential keys any more |
I ended up moving to Angular Material's Because of this, I'm unsubscribing from notifications on this issue. |
FWIW I had the same issue. It seems like I get into this issue if I use lodash cloneDeep() to clone the array for the rows. If I don't clone the array, it works just fine for me. |
@LuisUrrutia Thanks. I applied the same solution. |
I have a similar issues where in some cases the table would show nothing and no error when |
Any news on this? |
Pls refer this |
ERROR 💥 TypeError: Cannot read properties of undefined (reading 'toLocaleString') |
I'm submitting a ... (check one with "x")
Current behavior
When initializing a data table with the below code, the below error is printed to the console.
The following error (and its corresponding
DebugContext
) is logged to the console four times when I load my page:This is the value of the
component
property in theDebugContext
printed to the console:This is confusing to me, because all of the component's values seem to be defined. Also confusing because
DataTableFooterComponent.html:20
points to a line without any bindings on it, but that could just be a sourcemap problem:Despite the errors, the footer seems to render correctly:
Expected behavior
The table displays without logging any errors to the console.
Reproduction of the problem
The problem happens on page load. Could not reproduce in Plunker. Seems to be related to this commit.
What is the motivation / use case for changing the behavior?
This is a bug.
Please tell us about your environment:
macOS 10.12.5
VS Code 1.13.1
node 8.0.0, npm 5.0.0
Angular CLI 1.1.3
The text was updated successfully, but these errors were encountered: