Select extension not working with selecting first row

Select extension not working with selecting first row

NicolaiByNicolaiBy Posts: 3Questions: 1Answers: 1

Hi there

I have been trying various things, but I can't get it to select the first row automatically. The extension itself works fine and I can select rows manually.

I have read in other topics that people have had this working:

var table = $('#example').dataTable( {
"searching": false,
"paging": false,
"info": false,
"select": true
} );

table.row(':eq(0)').select();

But nothing happens - is there anyone with an idea for this?

Kindly regards

Nicolai

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,309Questions: 26Answers: 4,947

    Try changing the dataTable to DataTable:
    var table = $('#example').DataTable( {

    Check out the first FAQ here:
    https://datatables.net/faqs/index#Most-common-FAQs

    Kevin

  • NicolaiByNicolaiBy Posts: 3Questions: 1Answers: 1

    Hi there,

    Thanks for the input - however it did not solve the problem. I have tried with both dataTable as the example I posted and DataTable. Still not selecting the first row.

    I have a standard build, from the datatable builder with the select extension for the ccs and js files.

    I initiate both the table and the select in a $(document).ready(function() {

    Any other ideas?

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    Yes, post a link to a test case so we can take a look into it please :). I don't see anything wrong with the above. I might guess that the data was being loaded async, but that isn't shown in the above code.

    Allan

  • NicolaiByNicolaiBy Posts: 3Questions: 1Answers: 1
    Answer ✓

    Hi again,

    I had an error in some other code, which causes it to not correctly initiate the table.row(':eq(0)').select(); line. It has now been fixed and it now works as intended.

This discussion has been closed.