Rumpelstinsk
Rumpelstinsk

Reputation: 3241

Jquery Datatables: Set page from rowId

I need to set the default page from a recordId. After taken a look to: https://datatables.net/reference/option/rowId I have set a the rowsIds on my table:

$('#logosTable').DataTable(
            {
                serverSide: true,
                processing: true,
                searching: true,
                autoWidth: true,
                responsive: true,
                dom: 'rtip',
                ajax: {
                    url: '/Administracion/App/ObtenerListadoLogos',
                    type: "POST",
                    data:
                        function (d) {
                            d.DefaultLogo = $("#IdLogo").val()
                        }
                },
                rowId: 'Id',
                columns: [
                    { data: 'Id' },
                    {
                        data: 'Logo',
                        searchable: false,
                        orderable: false,
                        render: function (data, type, row) {
                            return '<img src="/DataBackend/ThumbnailsGallery/1/' + data + '" style="width:50px" />';
                        }
                    },
                    {
                        data: 'acciones',
                        searchable: false,
                        orderable: false,
                        render: function (data, type, row) {
                            return '<a href="#" onclick="seleccionarLogo(' + row.Id + ', \'' + row.Fichero + '\')"><i class="fa fa-check"></i> Seleccionar </a>';
                        }
                    }
                ]
            });

How can I set the default init page from a record id?

I have tried this: https://datatables.net/plug-ins/api/fnDisplayRow Howver on 1.10, it seems is no longer available. I have taken a look to: https://datatables.net/reference/api/ But it seems this functionality (and fngetNodes) has gone away.

Upvotes: 0

Views: 273

Answers (1)

J. Titus
J. Titus

Reputation: 9690

fnDisplayRow is a plugin that you need to include separately from the main DataTables library:

https://cdn.datatables.net/plug-ins/1.10.13/api/fnDisplayRow.js

There's an example using fnGetNodes() for 1.10 on the fnDisplayRow documentation page:

// Display the nth row in the table
var table = $('#example').dataTable();
table.fnDisplayRow( table.fnGetNodes()[n] );

Upvotes: 1

Related Questions