multiple tbody tags

multiple tbody tags

k0r54k0r54 Posts: 9Questions: 0Answers: 0
edited February 2010 in Bug reports
Hi,

Firstly - great plugin! Thanks for the hard work.

I have modified the fndraw function so it can support hidding rows. (ideal for a kind of grouping). It had a few bugs to begin with specificly with searching as it would find the row but not display it. All has been resolved with that. (code if you want is available).

This issue is more of a bug that does not allow me to use multiple tbody tags. I want to use the tablednd plugin with this and it works ok. However when i want to lock the drag and drop down into groups tablednd requires multiple tbody. This is where datatables falls over.

Is it possible to change the getelementsbytagname('tbody) to getelementbyid? It doesn't work when I make the change so was wondering your thoughts?

Thanks
k0r54

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi k0r54,

    At the moment DataTables fundamentally doesn't support multiple tbody tags I'm sorry to say. It is on the road map for a major upgrade at some point, should I get the chance to implement that - with the particular aim to allow row grouping. However, it should be reasonably easy to make DataTables simply read in information from multiple body tags, even if it can't really do anything with them. In the function _fnGatherData there is a line which reads oSettings.nTable.getElementsByTagName('tbody')[0].childNodes . Rather than using [0], you could just use a loop.

    Hope that helps,
    Allan
  • k0r54k0r54 Posts: 9Questions: 0Answers: 0
    edited February 2010
    Hi,

    Ok, I have decided to tweak the code some more. This for the most part works ok.

    This is the code and it works by removing the need for the tbody all together within the fnGatherData function. I did have to change the loop to start from 1 instead of 0 to exclude the header but I am sure an if statement can be put in to check the object is not within the thead.

    [code]
    /*
    * Process by row first
    * Add the data object for the whole table - storing the tr node. Note - no point in getting
    * DOM based data if we are going to go and replace it with Ajax source data.
    */
    if ( oSettings.sAjaxSource === null )
    {
    nTrs = oSettings.nTable.getElementsByTagName('tr');

    for (i=1, iLen=nTrs.length ; i
  • k0r54k0r54 Posts: 9Questions: 0Answers: 0
    edited February 2010
    I think I have inevertibly stumbled upon my problem.

    I think what is happening is it is not putting my back in. the fndraw is rebuilding the table when it initialise and is stripping it all down and then placing it back but without my tbody tags which is what is causing it to mess up.

    I think?

    Not at all sure what to do about it though lol I am guessing I will have to look at how it creates the anRows array and possibly create a parentNode or check for it.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    How about this as a solution - which would involve minimum modification to the DataTables code. At the start of the fnGatherData function, loop over the 1 to n tbody elements and move their child nodes (i.e the TRs) into the first tbody. Then DataTables will parse everything as normal. Although you loose any of the advantage of having multiple body elements - but then I think you probably would anyway.

    Regards,
    Allan
  • k0r54k0r54 Posts: 9Questions: 0Answers: 0
    Hi,

    I have tested that but I still cannot intergrate the tablednd which I need so I can dynamicly change the order.

    This is a great plugin and you help is grately appreciate. Within the fngathering function I have create a loop for all the bodys and so I think it is getting all the data.

    Now it is just the fndraw I need to look at so hopefully it can place the tbody back in the proper location.

    thanks
    k0r54
  • k0r54k0r54 Posts: 9Questions: 0Answers: 0
    edited February 2010
    Ok,

    Unfortunatly the project I am working means I have to move on from this. It works (to an extent) but it would be handy to know when you think the next version might be ready which will hopefully support multiple tbody tags so I can incorporate the tablednd function along with yours creating a powerful plugin.

    The main important thing for me is there does not need to be a root tbody. The table dnd function uses the tbody to allow you to drag and drop with the tbody body along. That means you can have areas in the table to are locked so you can order just within those areas. Having an outer tbody means it can drag and drop anywhere in the table and not have any constraints.

    The tablednd example i am basing it on is the one that has the headers
    http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/

    Thanks for your help so far and look forward to the next version.

    I will also donate some money in a couple of days when I get paid.

    thanks
    k0r54
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi k0r54,

    Thanks for investigating this - it's a very interesting topic.

    For updates you can subscribe to the RSS feed: feed://www.datatables.net/rss.xml . Although "true" tbody support is some way off! I think the best that could be hoped for in the short term is just to lump all the rows into one tbody - might not be good enough for dnd. I'll have a look at it.

    Regards,
    Allan
  • k0r54k0r54 Posts: 9Questions: 0Answers: 0
    Hi Allan,

    Yes I did create a scrip that would do that but unfortunatly made the dnd nun and void. I will keep an eye on the feed. Thanks for all your help and if you need anything just let me know
  • deolideoli Posts: 1Questions: 0Answers: 0
    Hi,

    DataTables is a great piece of work and making it compatible with TableDnD would make it awesome indeed.

    I've been looking at the latest code (v1.7.1) and the aforementioned code sections have changed considerably. Does this mean multiple tbody support is on the horizon?

    I don't mean to hassle in any way, I just wanted to show my interest in the subject.

    Regards,
    Oliver
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Oliver,

    Thanks for the interest! I've not got an immediate plans to add multiple tbody support for DataTables at this time. It something that I've been thinking about for the longer term DataTables 2 kind of thing, but not sure yet when that will happen - still plenty of life in the 1.x series yet ;-). Most certainly something that would be good to add though, as it would add a lot of flexibility.

    Regards,
    Allan
This discussion has been closed.