Confused about server side row details

Confused about server side row details

coolboyjulescoolboyjules Posts: 19Questions: 6Answers: 1

Hi everyone,

I'm trying to implement row-details for my server side processing DataTables. My table refreshes every 10 seconds and I want my row details to stay open! Currently they just close when it is reloaded. :neutral: In the example at

https://datatables.net/examples/server_side/row_details.html

I see there is this unique parameter 'id'. Somehow each row has this id defined in the DOM in the example. When I try to adapt the example verbatim, the 'id' attribute isn't defined, obviously, and the handler:

        dt.on('draw',
                    function () {
                        $.each(detailRows,
                            function(i, id) {
                                $('#' + id + ' td.details-control').trigger('click');
                            });
                    });

Doesn't fire.

My question:

Do I have to define the 'id' in the server side method to return to the client in the AJAX call? How do I give each row an id? My PHP knowledge is pretty bad so I virtually had no clue what was going on in the example.

Thanks! And I love this plugin!

Answers

  • coolboyjulescoolboyjules Posts: 19Questions: 6Answers: 1

    OK if anyone is confused with this turns out this link has some more info:

    https://datatables.net/reference/option/rowId

    Turns out you can set it manually as an option. I have a unique id for my entries so I just set

    rowId: 'Id'
    

    where 'Id' is the column name for my id field for my rows. Then everything works exactly as expected.

This discussion has been closed.