Row grouping with sorting - is this possible?

Row grouping with sorting - is this possible?

dimanchedimanche Posts: 3Questions: 0Answers: 0
edited April 2013 in DataTables 1.9
Hi, I´m very happy to see all the possibilities DataTables provides to us. Now I want to use it for an advanced user interface and need your help to figure out if it fits our requirements.

I tried to create a minimal example showing how I´d like to have it. The base table looks like this: http://imageshack.us/a/img89/2850/datatablesbeschreibungb.jpg

Most fields should be editable. I already tried jEditable which works good, so I can use select boxes and edit fields for this.

As you see, it is necessary to have many rows assigned to each person (here "Peter", "Sandra" and "Mike"). I probably could do something like this with a simple HTML table, but what if I want to sort? Sorting by name or creation date is not a big problem, but if I want to sort by any of the green columns, I would like to have a solution this: http://imageshack.us/a/img826/8672/datatablesbeschreibungs.jpg (here I sorted by the "first contact" date)

The data comes from a Perl application, so if it is needed, I could do the sorting thing by this application, not using the DataTables intelligence. But I would be happy if I could use most of the things DataTables already does.

What do you think? Is this possible? How should I go?

Thanks!
dimanche

Replies

  • dimanchedimanche Posts: 3Questions: 0Answers: 0
    edited April 2013
    Hi,
    I already found a way to realize the above asked, at least with many rows on the right side belonging to one on the left. I set the left white rows to color:white and background-color:white. It´s not a very elegant way, but it works for now.
    If I have more than one entry on the left, yellow part (here called countries), I will find a solution to put them all in one line.

    I also added the functionality of jEditable to some rows which works quite good.

    Is it possible to tell DataTables to redraw the table? I need to have the "fnRowCallback" run after the saving bei jEditable, because (1) the sorting gets wrong if not and (2) I have no chance to define another select entry for jEditable to be the new default selection.

    Any ideas?

    Thanks!
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I suspect that want to want to do (front he image) is going to be a bit tricky with DataTables since it is not designed for this kind of use case.

    It is possible, but it will be messy... So what I think you would want to do is use fnDrawCallback to manipulate the table's drawn nodes.

    This example uses FixedColumns (so you wouldn't want to use rowspan) but it sounds the kind of approach that might be taken: http://datatables.net/release-datatables/extras/FixedColumns/row_grouping_height.html .

    Personally the way I would approach this for your use case is to sort the table on the first two columns, and then use a loop to spin over the DOM for each column and set the text and background colour to white as you suggest. It sounds like this is what you are already doing. I don't think there is a more elegant way of doing it with DataTables I'm afraid.

    > Is it possible to tell DataTables to redraw the table?

    Absolutely - use the fnDraw API method - that will do a redraw.

    Regards,
    Allan
This discussion has been closed.