DataTablesSrc icon indicating copy to clipboard operation
DataTablesSrc copied to clipboard

Bugfix: Avoid "Uncaught TypeError: Cannot read property 'sWidth' of undefined"

Open takieszti91 opened this issue 5 years ago • 6 comments

while using column hider function (for example datatables.net-buttons/colVis).

takieszti91 avatar Nov 19 '19 09:11 takieszti91

Normally this issue is caused by defining more column than is in the HTML. Can you give me a link to an example showing the issue?

DataTables avatar Nov 19 '19 09:11 DataTables

I created 2 small examples for this: https://github.com/takieszti91/ErrorExampleForDataTables This error occurs when I use lightColumnFilter, scrollX and colvis at the same time.

takieszti91 avatar Nov 19 '19 13:11 takieszti91

You have to hide column(s) with the button.

takieszti91 avatar Nov 19 '19 14:11 takieszti91

Thank you for the example. I believe it is caused by:

	for (var i = 0; i < 6; i++) {
		$scope.columnfilter_object[String(i)] = {html: 'input', type: 'text'};
	}

It is always producing a 6 table column, but Angular is changing the DOM to only have 5 (or less) columns based on the click of the column selector. I believe the correct fix is actually to change that 6 to be dynamic based on the number of columns.

DataTables avatar Nov 20 '19 19:11 DataTables

I tried to change my code, but unfortunately I cannot change the original column filter. I can only add a new one. The error is still there. Can I change somehow the original column filter?

takieszti91 avatar Nov 21 '19 09:11 takieszti91

I'm afraid you'd need to ask the author of the column filter plug-in about that. That is not software that was developed by ourselves.

DataTables avatar Nov 21 '19 10:11 DataTables