How to render a div element in a cell (and use pagination)

How to render a div element in a cell (and use pagination)

emepycemepyc Posts: 8Questions: 2Answers: 0

Hi,
I need to render a div element inside a datatable cell and append children to that div. A minimal version of what I'm trying to to is in this jsfiddle: http://jsfiddle.net/emepyc/f9uf3suk/
I'm having a couple of problems with this:

  1. Searching doesn't fire "fnDrawCallback", which means that if you search for an entry not previously displayed, the div is not populated (in the fiddle, searching for "L", for example).
  2. I'm relying on settings._iDisplayStart and settings._iDisplayLength, but _iDisplayLength always give the max number of rows to display in the table (10) regardless how many are currently displayed (can be less).

A method that is fired on every redraw is fnRowCallback, but this is fired before the rows are rendered (so the div's have not been created yet).
Is there a way of doing this that I'm missing?
Thanks in advance!
M;

Answers

  • emepycemepyc Posts: 8Questions: 2Answers: 0

    I've solved this by using fnRowCallback and creating the div element there:
    Something like:

    "fnCreatedRow" : function (row, data, dataIndex) {
                        var div = document.createElement("div");
                        $(div).text("hello");
                        $(row).children("td:last-child").append(div);
                    },
    

    Updated jsfiddle: http://jsfiddle.net/emepyc/f9uf3suk/1/

This discussion has been closed.