server side processing error

server side processing error

calacala Posts: 52Questions: 15Answers: 0
edited October 2015 in Free community support

Hi to everybody.

I need to use server side processing (I have many thousand of rows) and, in the first cell of the row I linked a child row with the attached file(s). I want to show the + icon to open the row only if there is a file attached to that row (and this work(more or less, see PS note)).
Here is my cell code:

serverSide: true,
columns: [
            {
                "className":  'details-control',
                "orderable":      false,
                "data":           null,
                "defaultContent": ' ',
                render: function (data) {
                    //console.log ('data: ',data, "this: ", this, "$(this):", $(this)); 
                    if((data.afiles == 'null' )||(data.afiles.length === 0)){
                        $("#"+data.DT_RowId + ' .details-control').removeClass( 'details-control' );
                            return;
                    }
                    return;
                }   
            },
            ... other columns...
}]

But, when I search something a popup window error appear:

DataTables warning: table id=diego_table - Unknown field: (index 0)

How can I resolve this?

Thank you!

PS: I have another linked problem: I have an ajax reload button.

buttons: [
            { 
                text: 'Reload',
                className: 'reload-button',
                action: function ( e, dt, node, config ) {
                    dt.ajax.reload();
                }

When I click on it, the + icon re-appear near all the rows, the render function of the column is not executed again...

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,316Questions: 1Answers: 10,226 Site admin

    return;

    Change them both to be return ''; and that should do it. The issue is that you are returning undefined at the moment, which DataTables doesn't know what to do with (intentionally since it is undefined :-) ).

    Allan

  • calacala Posts: 52Questions: 15Answers: 0
    edited October 2015

    I tried it... but the error persists!

  • allanallan Posts: 62,316Questions: 1Answers: 10,226 Site admin
    Answer ✓

    Can you give me a link to the page in that case - I'll need to debug it.

    Hmm - also you can't use columns.render to add / remove classes since the cell might not exist at that point. You should use rowCallback in this case I think. Remove your render function entirely and reply with defaultContent: ''.

    Allan

  • calacala Posts: 52Questions: 15Answers: 0
    edited October 2015

    rowCallback works as a charm:

    "rowCallback": function( row, data, index ) {
        if((data.afiles == 'null' )||(data.afiles.length === 0)){
            $( this ).find("#"+data.DT_RowId + ' .details-control').removeClass( 'details-control' );
            $('td:eq(0)', row).removeClass( 'details-control' );
        }
    },
    

    Thank you!

  • calacala Posts: 52Questions: 15Answers: 0
    edited October 2015

    ...but the filter error remains!

  • allanallan Posts: 62,316Questions: 1Answers: 10,226 Site admin

    Can you link to the page so I can debugged why that error is occurring please.

    Allan

This discussion has been closed.