DT_RowData does not appear to be inserting data-* information using server-side processing

DT_RowData does not appear to be inserting data-* information using server-side processing

glendersonglenderson Posts: 231Questions: 11Answers: 29
edited July 2014 in Free community support

We currently use the DT_RowID to successfully insert the row ID on each data row (jSON based, server side ajax), so we're pretty sure our formatting and methods are okay.

We want to insert other attributes on the <TR> so we tried to use DT_RowData. we checked the demos, the documentation, etc., and created the jSON entry similar to "DT_RowData": {"mydata1":value1}, but the data-* attributes are not getting inserting in the <TR> element node.

We read back the attributes in other parts of our code. We were wondering if anyone might have gotten DT_RowData to work correctly and would you happen to have an example of the jSON data that you passed? We're not interested in using classes for this purpose so we're not considering that a viable alternative.

Answers

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    Decided to enhance datatables so it works correctly with <TR> row attributes.

    Around line 1680 ish of 1.10.1 -

    if (data.DT_RowData) {
        $(tr).data(data.DT_RowData);
    }
    ... new code
    
    // Adds attributes to the <TR> elements
        if (data.DT_RowAttr) {
            $.each(data.DT_RowAttr, function (i, val) {
                $(tr).attr(i,val)
            })
        }
    

    json format will be:

    "DT_RowAttr": {key1:"value1", key2:"value2", key3: value3"}

This discussion has been closed.