Row Children

Row Children

redpaintredpaint Posts: 5Questions: 0Answers: 0
edited May 2009 in General
Hi,

First off, let me just say that DataTables is great.

I was wondering if you had any plans to enable Children/Grouping of rows. I notice there is an option to group rows in v1.5 beta7, and I'm trying to work out how I could implement what I need using that as a starting point. I'm using the table to display a table of documents, and properties. A bit like the details view in Windows Explorer. I'd like to have the facility to display children, I suppose a bit like a tree menu. Is this possible?

Thanks

Replies

  • allanallan Posts: 63,532Questions: 1Answers: 10,475 Site admin
    Hi redpaint,

    If I understand correctly then what you are looking for is the fnOpen() and fnClose() functions. There are two examples of this available at the moment, one for client-side processing and another for server-side processing:

    http://datatables.net/1.5-beta/examples/api/row_details.html
    http://datatables.net/1.5-beta/examples/server_side/row_details.html

    Also here is the example showing row grouping that you mentioned in your post:

    http://datatables.net/1.5-beta/examples/advanced_init/row_grouping.html

    Is any of these links what you are looking for?

    Regards,
    Allan
  • redpaintredpaint Posts: 5Questions: 0Answers: 0
    Hi Allan,

    Thanks for the response. The examples you've given are along the right lines, what I'm looking for is something that would fire post-initialisation and be based on the data. Only some table items would need additional info not all rows.

    I suppose what I'm looking for is something like this: http://ludo.cubicphuse.nl/jquery-plugins/treeTable/doc/index.html#example-1 or a way of doing something similar. DataTables is the tool we want to work with we just aren't sure if this type of thing would be possible?

    Many Thanks
    Andy
  • allanallan Posts: 63,532Questions: 1Answers: 10,475 Site admin
    Hi Andy,

    Thanks for the link - that would certainly be an interesting application of DataTables! I believe what you are looking for could indeed be done - and there are a couple of ways of doing it.

    Firstly, as you noted, you'll need some kind of grouping. What you could do there is make use of the "aaSortingFixed" parameter (it's new in 1.5 so not yet documented, but is exactly the same as aaSorting). This parameter will ensure that a column is always sorted on first, no matter what the user requests the sorting to be. Using this in-combination with a hidden column which includes information about the hierarchy will ensure your grouping.

    Regarding the pattern of having rows show and hide. This might best be accomplished by using the fnAddData() and fnDeleteRow() API functions. Another option is to display all rows initially and then filter them as needed, however I believe fnAddData() and friends allow for more flexibility.

    How does that sound?

    Allan
  • redpaintredpaint Posts: 5Questions: 0Answers: 0
    Hi Allan,

    Sounds very interesting, I was looking for a way of ensuring that columns were always sorted on a specific row first, regardless of user selection. aaSortingFixed sounds ideal.

    With fnAddData() and fnDeleteRow() I think it might just be possible to do what I need! I'll spend some time looking at this and try and come up with an example. If and when I do I'll email you the source code.

    One other thing I thought might be useful, and I think it would need to be used in conjunction with an external datasource but the possibility of moving individual rows. A bit like fnAddData() and fnDeleteRow() but with the facility to move the row up or down by passing an argument to the function. This could be interfaced with a drag/drop function or a simple up/down button. What do you think?

    Thanks again
    Andy
  • allanallan Posts: 63,532Questions: 1Answers: 10,475 Site admin
    Hi Andy,

    If you do make any progress with this I would be most interested in seeing what you come up with. You can get in touch with me here: www.datatables.net/contact .

    Regarding the moving of rows - rows are moved around in DataTables by the sorting, so there is already provision for something like what you are looking for (minus the drag and drop!). To move a row you just need to alter the data in the column that it is currently being sorted on. So if you have a hidden column you are using with aaSortingFixed, you can just change the information in that row/column (see fnUpdate - http://datatables.net/api#fnUpdate ).

    Regards,
    Allan
  • merihmerih Posts: 24Questions: 0Answers: 0
    Hi allan,

    I need to use treedatable, which you discuss above, on my project. I just wanted to know did you developed this kind of plug-in?
    This is what I need,
    http://ludo.cubicphuse.nl/jquery-plugins/treeTable/doc/index.html#example-1

    Thanks,
    Merih
This discussion has been closed.