Bootstrap-table: Uncaught TypeError: Cannot read property 'field' of undefined

Created on 27 Jul 2015  路  19Comments  路  Source: wenzhixin/bootstrap-table

Uncaught TypeError: Cannot read property 'field' of undefined
bootstrap-table-error
bootstrap-table-error

(anonymous function) @ bootstrap-table.min.js:7n.extend.each @ jquery.js:374n.fn.n.each @ jquery.js:139(anonymous function) @ bootstrap-table.min.js:7n.extend.each @ jquery.js:374n.fn.n.each @ jquery.js:139o.initTable @ bootstrap-table.min.js:7o.init @ bootstrap-table.min.js:7o @ bootstrap-table.min.js:7(anonymous function) @ bootstrap-table.min.js:8n.extend.each @ jquery.js:374n.fn.n.each @ jquery.js:139a.fn.bootstrapTable @ bootstrap-table.min.js:8(anonymous function) @ bootstrap-table.min.js:8n.Callbacks.j @ jquery.js:3099n.Callbacks.k.fireWith @ jquery.js:3211n.extend.ready @ jquery.js:3417I @ jquery.js:3433

Most helpful comment

Hey there,

I just finished troubleshooting this same issue, make sure your table includes table header and table body tags:

<thead></thead>
<tbody></tbody>

Sorted

All 19 comments

I am new to bootstrap-table but when I included the bootstrap-table to my application

ex:

I have tried using table example from bootstrap-table but the error keeps popping all the time.

Can you provide a jsFiddle to show your problem?

Hey there,

I just finished troubleshooting this same issue, make sure your table includes table header and table body tags:

<thead></thead>
<tbody></tbody>

Sorted

You nailed it. My table had no <thead> and no <tbody> . After adding I get no " Uncaught TypeError: Cannot read property 'field' of undefined "

Thank you CathalG

Please use a standard table.

@CathalG You just saved my time. thank you. it works after adding

<thead></thead>
<tbody></tbody>

What about warning that the table is missing this fields? I lost some time on this, because I was using an ASP.Net MVC sample table...

I came across this issue because I had more columns than headers in my table. Hope this could help someone

This error message also occurs if the number of

-elements is unequal the number of -elements

I got the same error message. I have <thead> and <tbody>, number of header columns equals the number of columns in tbody, tags are all closed. Is there another problem leading to the same error message?

@rachelluethi Please provide us an example using our online editor

Reopened it for tracking purposes

The problem was that colspan is not considered in <thead> (?). I could solve it by adding the same amount of <th> in <thead> as the sum of colspans defined.

Example:

<thead>
   <th></th>
   <th></th>
   <th></th>
   <th></th>
   <th></th>
</thead>
<tbody>
   <tr colspan="1"></tr>
   <tr colspan="3"></tr>
   <tr colspan="1"></tr>
</tbody>

@rachelluethi as already said, please provide a example using our editor.

rowspan and colspan works in the thead, check this example: https://live.bootstrap-table.com/example/column-options/rowspan-colspan.html

Im not sure if we support colspan/rowspan on the tbody.
There is a method called mergeCells : https://examples.bootstrap-table.com/#methods/merge-cells.html

@wenzhixin @djhvscf could you check this ?

I think you can use the mergeCells method in order to do that

Thank you!
I added a working and a non-working example:
https://live.bootstrap-table.com/code/rachelluethi/3433
https://live.bootstrap-table.com/code/rachelluethi/3434

Duplicate of #4562

Adding my $0.02 worth:
I had this exact same issue and after reading this thread, was able to solve my problem. My table was set up like this with a td instead of a th like so:

<thead>
   <td></td>
   <th></th>
   <th></th>
   <th></th>
   <th></th>
</thead>

This falls under @BeardyB 's comment above regarding unequal number of elements. Hope this helps someone.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

antonioaltamura picture antonioaltamura  路  15Comments

iamthestreets picture iamthestreets  路  26Comments

havok2063 picture havok2063  路  39Comments

marccollin picture marccollin  路  15Comments

jesussuarz picture jesussuarz  路  17Comments