Datatable creates two tables in scrollY mode

Datatable creates two tables in scrollY mode

adsoodadsood Posts: 10Questions: 0Answers: 0
edited September 2011 in General
Hi all,

When datatable is used in scrollY mode it actually creates two DOM tables - one for the content and one for the header to make it detached from scrolling.

I create datatable dynamically with the code like that:
var $table = $("").appendTo($container);
$table.addClass(UIClasses.Table);

then initialize datatable here:
var oTable = $table.dataTable(cur_data);

Later I would identify the created table by jQuery select using UIClasses.Table class:
var $table = $("." + UIClasses.Table, $container);

That seems quite simple, however, in scrollY mode datatable creates another DOM table element for the table header and it seems that it copies class from the main table to the header. As such, when I query for the table node using jQuery: $("." + UIClasses.Table, $container); I receive two elements as the result.

My question is:
How can I distinguish between the two and find the reference to the main table?


P.S.
Currently I am using a workaround, which I would like to remove in favor of a better way :
//todo: hack: skipping the header;
if (this.$table.length > 1)
this.$table = $(this.$table[this.$table.length-1]);

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    [quote]$("")[/quote]

    unless jquery is adding thead and tbody tags for you, this is not supported.
  • adsoodadsood Posts: 10Questions: 0Answers: 0
    Are you saying that I have to provide tags for thead and tbody in the initial markup?
    What about tfoot ?
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    tfoot is optional.

    add the thead and tbody, see if that helps at all.. ?
This discussion has been closed.