unable to extract child row values

unable to extract child row values

apallavapallav Posts: 26Questions: 3Answers: 0

https://jsfiddle.net/1k8et0sd/8/**:
**Debugger code (debug.datatables.net)
:
Chidl rows returning NaN:
Description of problem:

Hi Please see my fiddle here : https://jsfiddle.net/1k8et0sd/8/

For the life of me I can not figure out why 'data-child-value' values are not passing on to format function.

Appreciate your input.

AP

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,289Questions: 26Answers: 4,943
    edited April 22 Answer ✓

    You are trying to use the jQuery data() method which doesn't expect the leading data-. I think this is what you want:

     row.child(format(tr.data('child-value'))).show();
    

    Updated example:
    https://jsfiddle.net/12ubaLd9/

    Kevin

  • apallavapallav Posts: 26Questions: 3Answers: 0

    Oh my goodness! Thanks for your help!

  • apallavapallav Posts: 26Questions: 3Answers: 0

    HI Kevin.

    Me again. How do I add conditional styling (based on regex such as cell value is PASS, FAIL etc )to child table cells. I am looking to add text background color

  • kthorngrenkthorngren Posts: 21,289Questions: 26Answers: 4,943

    Use createdRow as shown in this example.

    Kevin

  • apallavapallav Posts: 26Questions: 3Answers: 0

    I can't quite get it. Could you please help.

    Please see updated fiddle here:

  • allanallan Posts: 63,434Questions: 1Answers: 10,458 Site admin

    You are running $('#mchild').DataTable({ when the page is loaded, rather than when the child row / table is created. As such, the child table isn't found, and thus can't be created as a DataTable.

    You need to run the initialisation for the child table after you insert it into the document - i.e. after the row.child(...).show() call.

    I would suggest you create a function that will initialise the inner table, and pass in the inner table node, rather than using an id (since an ID must be unique on a page, and if you showed two child tables at a time, that would break at the moment).

    Allan

  • apallavapallav Posts: 26Questions: 3Answers: 0

    Hi Allan and Kevin,
    Thanks for taking time to help.
    I followed another lead from this forum to achieve what I am looking for.

    Example here.

  • apallavapallav Posts: 26Questions: 3Answers: 0

    I have one more question though.

    I would like to append couple of rows ( csv ) or inner html text perhaps when exporting table in excel format. I am using buttons and following customize function. How do I append content to last row?

    Alternatively, is there a way to have hidden rows in a dateable and be able to export?


    customize: function ( xlsx ) {
    var sheet = xlsx.xl.worksheets['sheet1.xml'];
    $('row:first c', sheet).attr( 's', '2' ); // bold header row
    var attr = $('row', sheet).length;
    attr.append( 'Gene,Target,Mean Coverage' ); // this is right syntax?.
    }

  • kthorngrenkthorngren Posts: 21,289Questions: 26Answers: 4,943

    The easiest way to append rows to the bottom is to use the messageBottom option. See this example of using messageTop. You can do the same with messageBottom.

    Kevin

  • apallavapallav Posts: 26Questions: 3Answers: 0

    Hi Kevin,
    please see the code below.

    message bottom row is spanning across table columns. How do I make them as individual rows.?

    Data is center aligned. How do I make it left aligned?


     messageBottom: function() { return 'Target,Mean Coverage'+String.fromCharCode(10)+
                                                                                                 'TIMM8B_NM_012459.4_1,28.20'+String.fromCharCode(10)+
                                                                                                 'POLR1G_NM_012099.3_3,0.27'+String.fromCharCode(10)+ 
                                                                                                 'VRK2_NM_006296.7_12,11.61'+String.fromCharCode(10)
                                                                                            }
    
  • allanallan Posts: 63,434Questions: 1Answers: 10,458 Site admin

    You'd need to use the customize callback of the excelHtml5 button type to modify the XML that is created for the output. For that you'll need:

    It exporter isn't really designed for easy modification - that would be a whole project in and off itself. SheetJS for example might be of interest if you need "real" customisation of the Excel export beyond fiddling with some XML.

    Allan

  • apallavapallav Posts: 26Questions: 3Answers: 0

    Sure. I understand.

    Left aligning the message bottom would work for me. How do I do that?

  • allanallan Posts: 63,434Questions: 1Answers: 10,458 Site admin

    Apply style 50 to the cell in question. The example shows how to set style 2 to all cells for a particularly column. You'd need to use a selector that picks out the specific cell you want - possibly row:last-child c, but I haven't tried it.

    Allan

Sign In or Register to comment.