[how do it] Row grouping

[how do it] Row grouping

pakypaky Posts: 106Questions: 0Answers: 0
edited October 2009 in General
Hi all, I read 'row grouping' example but for my case, I've any employees for each of these any timetable ... my query is a normal >INNER JOIN< for goup on employees ?

thanks

paky

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Hi paky,

    I'm not sure how you are looking to modify the row grouping demo. It might be fairly instructive to disable Javascript on that page, see how the grouping is done, and then re-enable Javascript to see the effect. Basically the first column (the browser engine) is the group, and that is always sorted upon first (before user sorting) by using aaSortingFixed. Remember an Inner Join doesn't mean anything to DataTables - it's how the data is presented to it, since it doesn't directly interface with SQL itself (there must always be PHP or something in the middle).

    Regards,
    Allan
  • pakypaky Posts: 106Questions: 0Answers: 0
    edited October 2009
    Hi Allan, yes I've php code for read data from mysql .... therefore I must put in first column ... inner join not but 'order by' ? neither ?

    P.S.
    If in my case column for group is not the first but the second ? Where I change the index ?

    thanks
  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    HI paky,

    I'm not sure how your SQL is going to be working (the inner join etc), but as long as you output the HTML required, than DataTables can do the row grouping, as shown in my example. Have you tried disabling Javascript to see how my table is built up (or just 'view source')? From there, my code might make a bit more sense. Also aaSortingFixed is the key thing for controlling the sorting here - have a look at the documentation ( http://datatables.net/usage/options#aaSortingFixed ).

    Regards,
    Allan
  • pakypaky Posts: 106Questions: 0Answers: 0
    Hi allan now it's all ok .... or almost. In firefox ok in IE8 return a error (warning, added data does not match etc...), my json string is valid (with jsonlint) .... where's the problem ?!


    my json string:
    {"sEcho": 1, "iTotalRecords": 13, "iTotalDisplayRecords": 13, "aaData": [ ["Mister_x","01-07-2008","31-01-2010","durata_x"]] }

    my table (thead) structure:
    [code]


    User
    start
    end
    Duration


    [/code]

    datatable (aoColumns) option:
    "aoColumns":
    [
    { "bVisible": false },
    null,
    null,
    null
    ]


    ==============================================
    thanks
  • pakypaky Posts: 106Questions: 0Answers: 0
    [>solved<]

    in datatable parameters:
    [code]
    "aoColumns": [
    { "bVisible": false },
    null,
    null,
    null
    ],
    "aaSortingFixed": [[ 0, 'asc' ]],
    "aaSorting": [[ 0, 'asc' ]], // <---- comment this useless line
    "sDom": 'lfr<"giveHeight"t>ip',
    "bProcessing": true,
    "bServerSide": true,
    [/code]

    byez
This discussion has been closed.