How do I get to show up?

How do I get to show up?

dtUser2011dtUser2011 Posts: 11Questions: 0Answers: 0
edited June 2013 in General
Hi,

I'm new to jQuery DataTables api, and I added a row to my table using the API. However, the section does not show up. What do I need to do to get the body to show up per row that I add to the table?

I have a link to the sample code: http://live.datatables.net/uhunib/3/edit

Thanks for your help!

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    You had four columns defined, but only one in the table on first load. That doesn't go down so well with DataTables :-)

    http://live.datatables.net/uhunib/4/edit

    Allan
  • dtUser2011dtUser2011 Posts: 11Questions: 0Answers: 0
    Thanks for your response Allan! I'm still not sure I understand. I tried your link, but it doesn't look like the solution is there?
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    In what way? If you click the Render button the table renders correctly. What are you expecting to happen?

    Allan
  • dtUser2011dtUser2011 Posts: 11Questions: 0Answers: 0
    If I put something in the table body, I expect it to show up beneath the row I just added. For example, if I have the following code, it doesn't show up, so how do I get it to show up?



    Connection State
  • aaronwaaronw Posts: 89Questions: 3Answers: 4
    so fnAddData adds a row (of data) to the bottom. As the live example has it, you have just one row you're inserting, and it's showing up as expected.

    I see in your example (http://live.datatables.net/uhunib/3/edit#javascript,html)

    you have
    [code]



    Connection State




    [/code]

    Are you wanting this 'connection state' to be another column, or a row 'header'? Typically speaking in a database table, one has all of their data for one 'item' in one row, and the columns are the informational aspects of that row (server node name, server port name, etc). What kind of information do you want to convey by 'connection state' ?
  • dtUser2011dtUser2011 Posts: 11Questions: 0Answers: 0
    Hi,

    Sorry, I guess I wasn't clear on what I was expecting. I want the output to look something like the following:


    Server Port WWN | Server Node WWN | Server Port Name | Server Node Name
    -------------------------------------------------------------
    a | b | c | d

    connection-state Active
    -------------------------------------------------------------
    e | f | g | h

    connection-state Disabled
    -------------------------------------------------------------

    So, I have two rows in the table, and each row has a connection-state field (and possibly other fields if I decide to add some more later). How do I do this?
  • aaronwaaronw Posts: 89Questions: 3Answers: 4
    So actually, the way you need to think about this is that you don't have 2 rows in the table - you actually have 4 rows -- 2 with 1 td for each td in the thead (you should probably use instead of for stuff in the header, but I digress), and then 2 rows with 1 td that you would need to do so that it would span all the other columns. The problem is that generally speaking each row is assumed to be independent. For example, if you resort based on server node name, then what happens to your extra rows with connection-state? Is there a reason you're not just adding additional columns ('Connection State' or 'Country Location') and then just populating that row with that info (Active / Disabled) or something like that?
  • psharppsharp Posts: 39Questions: 0Answers: 0
    edited June 2013
    Take a look at the row groupings plugin. This will do exactly what you need.
    You will probably have to add an additional (hidden) field that tells the status of the record (enabled / disabled).

    edit:

    look here. It will do what you are needing.
    http://www.datatables.net/examples/advanced_init/row_grouping.html
  • dtUser2011dtUser2011 Posts: 11Questions: 0Answers: 0
    Thanks -- I'll try that out!
This discussion has been closed.