First line in with Row Details.

First line in with Row Details.

ilamilam Posts: 9Questions: 3Answers: 0
edited September 2014 in Free community support

Hi,
I use http://datatables.net/examples/api/row_details.html
I shall like that the first line is show when the page displays. I try to use

table.row( ':eq(0)' ).child( [
        'First child row',
        'Second child row',
        'Third child row'
    ] )
    .show();

to activate the first line but it does not work.
Anybody can help me?
Thx,

Answers

  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin

    Hi,

    That looks like it should work to me. Can you link to a test page showing the problem so I can debug it please?

    Allan

  • ilamilam Posts: 9Questions: 3Answers: 0

    Hi Allan,

    This is the code to debug: http://live.datatables.net/jomeqena/1/
    The same that http://datatables.net/examples/api/row_details.html , I just add

    table.row( ':eq(0)' ).child( [
            'First child row',
            'Second child row',
            'Third child row'
        ] )
        .show();
    

    I have probleme to add ajax data with the live.datatables.net: there are only HTML, JS, CSS and console but not ajax.
    So this is the ajax data (objetcs.txt):

    {
        "data": [
            {
                "name": "Tiger Nixon",
                "position": "System Architect",
                "salary": "$320,800",
                "start_date": "2011\/04\/25",
                "office": "Edinburgh",
                "extn": "5421"
            },
            {
                "name": "Garrett Winters",
                "position": "Accountant",
                "salary": "$170,750",
                "start_date": "2011\/07\/25",
                "office": "Tokyo",
                "extn": "8422"
            },
            {
                "name": "Ashton Cox",
                "position": "Junior Technical Author",
                "salary": "$86,000",
                "start_date": "2009\/01\/12",
                "office": "San Francisco",
                "extn": "1562"
            },
            {
                "name": "Donna Snider",
                "position": "Customer Support",
                "salary": "$112,000",
                "start_date": "2011\/01\/25",
                "office": "New York",
                "extn": "4226"
            }
        ]
    }
    

    I want to display the first line (or first two) with an expand first row; + column would be activated immediately upon posting of the first line (or first two lines).
    I add

    table.row( ':eq(0)' ).child( [
            'First child row',
            'Second child row',
            'Third child row'
        ] )
        .show();
    

    in JS but i think that i make a mistake.
    Can you help me?

    Thx,

  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin

    I get errors when trying to use that test case ( http://live.datatables.net/jomeqena/2/edit ).

    Perhaps I should have qualify my statement with, can you link to a live and working test case showing the problem rather than just the code. I will debug the code later on today if I have time, but I don't have a huge amount of spare time at the moment.

    Having said that, the one thing that immediately stands out for me, when scanning the code is that you are Ajax loading the data, but not waiting for the data to be loaded before trying to open the first row. Use initComplete for that.

    Allan

  • ilamilam Posts: 9Questions: 3Answers: 0

    Hi Allan, sorry for the delay,

    I think that my explanations were not clear. and I have difficulty in using the live datatables.

    I use Child rows, I take the same for the example: http://www.datatables.net/examples/api/row_details.html

    We have the result 1 when the web page loads,
    I try to obtain the result 2.

    What script has to I use? And where I have to place it?

    Thank you;


    Result 1 (We have this result 1):

    alt text


    Result 2 (I try to obtain this result 2.):

    alt text

  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin

    If you want only one row "open" at a time, you will need to loop over all other rows (using rows().indexes()) and check if they are open or not (row().child.isShown()). If it is, close it.

    Another option is to use a local variable to keep track of the open row and close if it required.

    Allan

This discussion has been closed.