0

I'm using the jquery datatables plugin and I wanted to have a collapse and expand feature as:

http://datatables.net/examples/api/row_details.html

the data i am loding in is coming via html how should i structure the html table content so that it collapses / expands?

Thanks


UPDATE

Thanks for getting back to me, they have a pretty bog standard table which is fine, but they have this function in the js:

/* Formating function for row details */
function fnFormatDetails ( oTable, nTr )
        {
        var aData = oTable.fnGetData( nTr );
            var sOut = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">';
            sOut += '<tr><td>Rendering engine:</td><td>'+aData[1]+' '+aData[4]+'</td></tr>';
            sOut += '<tr><td>Link to source:</td><td>Could provide a link here</td></tr>';
            sOut += '<tr><td>Extra info:</td><td>And any further details here (images etc)</td></tr>';
            sOut += '</table>';

            return sOut;
        }

I'm not sure how this is changing the table structure but this is being added which allows the collpased content in the table.

I want to just generate one html table with out using the script above.

4
  • I'm confused, isn't that exactly what the example is doing? They have an HTML table that they are using to load the data. How is your problem different? Jun 16, 2011 at 19:11
  • Hi I have added an update above which hopefully explains things better.
    – Dino
    Jun 16, 2011 at 19:17
  • I've done complex things like that, this part of the code defines what is addedd to the table when you press the plus sign as you correctly state, why don't you want to use it?you can customize it as you want: you want data added to the table to be taken by an ajax source? Jun 17, 2011 at 7:29
  • I thought it would be easier for me to return the full html of the table with expand /collapse rows via ajax, as in the expanded row I was thinking of having varying content, and not structured content as the code usd above. Thanks
    – Dino
    Jun 19, 2011 at 1:31

1 Answer 1

0
**jQuery Datatable** have inbuilt features for expand and collapse row.
use the js fiddle for example : 

http://jsfiddle.net/dvgotLfz/5/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.