Skip to content

Uncaught TypeError: element.getAttribute is not a function when within a table #524

Closed
@Chrsab

Description

@Chrsab

I'm using the latest version of jexcel v3. When using a jexcel spreadsheet within a table I get Uncaught TypeError: element.getAttribute is not a function at GetCellCoords when using pagination etc. See example below:

<table>
<tr>
<td>
<div id="spreadsheet"></div>
</td>
</tr>
</table>

<script>
jexcel(document.getElementById('spreadsheet'), {
csv:'/demo.csv',
csvHeaders:true,
search:true,
pagination:5,
paginationOptions:[10,25,50,100],
columns: [
{ type: 'text', width:120, readOnly:true },
{ type: 'text', width:100, readOnly:true },
{ type: 'text', width:100, readOnly:true },
{ type: 'text', width:100, readOnly:true },
{ type: 'text', width:100, readOnly:true },
]
});
</script>

When it's outside a table it works perfectly. Anyway I can resolve without having to take out of the table?

Activity

pphod

pphod commented on Nov 5, 2019

@pphod
Contributor

Did you try the most recent version? I guess this has been fixed. If not can you create a jsfiddle to explain more about the problem?

alberto-ita

alberto-ita commented on Apr 9, 2020

@alberto-ita

Hi Paulhodel I'm using your jexcel v4.
First Thanks you for your work, I really appreciate.
I tested jexcel on the local server, and on a "normal" page everything works normally.
Then I put the page in a job I'm doing; the situation is this:
I have a Parent page that makes load() calls and loads the pages into a DIV (as you normally do).

$('#mybutton').click(function(){ $("#myDiv").load("my-jexcel-page.php"); });

The page loads normally and jexcel works "almost" normally.
If I click in the column header or pagination buttons, I receive this error (on the console):
Uncaught TypeError: element.getAttribute is not a function
refered to line 6807 on jexcel.js

Please note that the jquery and the jexcel are on the parent page and the script work well if the page is not loaded by jquery.
Can you have some suggestions to solve ? Thanks
Alberto

alberto-ita

alberto-ita commented on Apr 9, 2020

@alberto-ita

Hello Paulhodel
for now i found a solution, little dirth, not your solution.
The problem maybe was caused by some conflict with jQuery;
at the line 6807 i changed the code

var x = element.getAttribute('data-x');
var y = element.getAttribute('data-y');

with

var x = $(element).attr('data-x');
var y = $(element).attr('data-y');

Thanks again, and if you have a clean solution, please write.
Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @pphod@Chrsab@alberto-ita

      Issue actions

        Uncaught TypeError: element.getAttribute is not a function when within a table · Issue #524 · jspreadsheet/ce