webinarium / DataTablesBundle

Symfony bundle for DataTables plugin.
MIT License
16 stars 9 forks source link

Symfony 4: Uncaught TypeError: Cannot set property 'data' of null #9

Closed CelineGardier closed 6 years ago

CelineGardier commented 6 years ago

I'm getting the following error in de developer console: Uncaught TypeError: Cannot set property 'data' of null

Any idea where I can start looking into this error? If I just go the route that returns the data, I'm getting; "This value should not be null."

CelineGardier commented 6 years ago

I found the solution: I was adding the data source after initialisation and refreshing the table which didn't give the correct URL to get the data. Solved it by using a data attribute to link to the data source at initialisation.

ghost commented 6 years ago

@CelineGardier can you perhaps show code examples of how you fixed this issue?

When I go to the route that should return the data I get the same "This value should not be null." message.

CelineGardier commented 6 years ago

@CelineGardier can you perhaps show code examples of how you fixed this issue?

When I go to the route that should return the data I get the same "This value should not be null." message.

Good question. I don't have the project at hand anymore but tried it by setting the link to the data source in a data-attribute and see if that gives the correct URL/dataset <table id="myid" data-url="url-to-data"> ... var url = $("#myid").data("url"); $("#myid").DataTables({ "ajax": url });

from the top of my head so not tested :)