Responsive extension and render

Responsive extension and render

jd0000jd0000 Posts: 25Questions: 6Answers: 0

In the responsive extension, I'm trying to use (either the default or ) a custom render function. I seem to only be able to get the raw data. How do I reference either the rendered data directly (that uses my column's rendering function), or get access to the columns rendering function from within { responsive: { details: { renderer: function } } } to render the raw data?

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    The row().cache() method will let you access the data that has been cached for searching and / or ordering. In this case, you probably want to access the search cache (since the ordering data might not be available if the column hasn't been ordered).

    Allan

  • jd0000jd0000 Posts: 25Questions: 6Answers: 0
    edited July 2014

    So if i edit your rendered function for testing i get ...

    renderer: function ( api, rowIdx ) {
                                    // Select hidden columns for the given row
                                    var data = api.cells( rowIdx, ':hidden' ).eq(0).map( function ( cell ) {
                                        var header = $( api.column( cell.column ).header() );
    
                                        console.log( "row: ", api.row( cell.row ) );
                                        console.log( "data: ", api.row( cell.row ).data() );
                                        console.log( "cache: ", api.row( cell.row ).cache() );
                                        console.log( "cache S: ", api.row( cell.row ).cache('search') );
                                        console.log( "cache O: ", api.row( cell.row ).cache('order') );
    ...
    

    What i get for output is

    row: [the object]
    data: [ object with the raw data ]
    cache: null
    cache S: null
    cache O: null

    So i'm not sure if I'm doing something wrong or its not working.
    And I'm apparently incapable of learning how to use markdown for formatting.

  • jd0000jd0000 Posts: 25Questions: 6Answers: 0

    I created an example here:
    http://live.datatables.net/xemoney/1/edit?html,js,console,output
    I'm not sure how to access the row.cache from there --- unlike my local test, which outputs null, when i write out the row cache here it prints out i think the whole dataTables object (and slows jsbin to a crawl). Is there anyway in this example for me to get it to render like it should with the RENDER whatever?

    (Thank you!)

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin
    Answer ✓

    Hi,

    Your Markdown was fine :-). The only thing is to get a line break, use a double space at the end of a line (thinking of changing the Markdown used here to do that automatically...).

    Thanks for the live example. I used api.cell( cell ).cache('search') in it and it appears to do what is required I think: http://live.datatables.net/xemoney/2/edit . Is that what you are looking for?

    Allan

  • jd0000jd0000 Posts: 25Questions: 6Answers: 0

    Yes thats exactly what I was looking for.
    Unfortunately, while it works on the live datatables site, it doesnt work on my code. I have a convoluted way of creating the datatables initialization options object so maybe its something i did wrong in there. With the only change being ( "api.cell( cell ).cache('search')" replacing "api.cell( cell ).data()"), when I go to expand the row I now get

    TypeError: settings.aoData[row][type] is null
    return settings.aoData[ row ][ type ][ column ];
    on line 8373 - which is in the api_registerPlural function for cells().cache.
    When debugging and looking at the object, for each row in aoData, _aSortData, _aFilterData, and _sFilterRow are null.

    I'll keep playing with different options on my site to see what i can figure out.
    Thanks for taking a look.

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    Are you using server-side processing or something else perhaps?

    Allan

  • jd0000jd0000 Posts: 25Questions: 6Answers: 0

    Yes this is server-side. i msged over the debug page (btw, i dont think the debug page recognizes Responsive yet)

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin
    Answer ✓

    Good point about the debug page - had forgotten to update it!

    Thanks for the debug trace. The problem is that you are using server-side processing. Since server-side processing is used there is no filtering at the client-side, so there is no cached data.

    In which case, the only want to get the rendered text is to read it from the document - $( api.cell( cell ).node() ).html(); would do it.

    Allan

  • jd0000jd0000 Posts: 25Questions: 6Answers: 0

    That was it. perfect. thanks again!

  • stefanosgeostefanosgeo Posts: 1Questions: 0Answers: 0
    edited September 2014

    Hi Allan,

    Thank you for your answers...You are really great.

    I set the DT in our dev server both with server and client side. We choose for the moment the client side option. But in the responsive design (with client side) I used the node().html option and it is working only in the first page results. Is this because the page is cached? Can I somehow have the same cached data in all pagination pages?

    I have a custom rendering row via fnRowCallback. I have some checks and I output a link with the button in the last column.
    The next page (and all the pages) the hide cells are using the data before the custom rendering (for example in last cell I get ColumnName : 1 ...

    In the example with the server side processing is working fine in all pages...

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    Not sure, can you link to the page please. You might have deferred rendering enabled.

    Allan

This discussion has been closed.