I'm not entirely sure what you mean I'm afraid. What do you mean by a "row group"? The only add data function (off the top of my head) is this one: http://datatables.net/examples/api/add_row.html . It should be possible to integrate this with the row grouping example, just by adding the required data.
I think I see what you mean - and all that I think you need to do is add the data to the table as you would for a non-grouped example. Remember that the grouping is done by the sorting, so if I were to add a new row with 'Gecko' in the first column it would automatically be put into the 'Gecko' group.
Yes, no reason why that shouldn't be possible. When you are looping for the rows to look for the groups and then add the new TR/TD element for the group, why not just total up the information and add it in there (i.e. in fnDrawCallback).
I'm not inclined to just bash out code (since nobody learns that way, including me!), but hopefully I can point you in the right direction.
In the fnDrawCallback function you have, you are looping over the TR elements in the table, checked on each loop to see if there is a new "group" required. It is trivial to modify this to add up the totals for each group - so I would suggest starting there (just getting the value from the DOM and adding it to a variable) and either alert() or console.log() that. Once that is going, you just need to enter your calculated value into the group row you created - again DOM methods will let you do this.
Looks good. So the issue now is just colspan etc is it? The nCell variable always uses colspan, so perhap you can just modify that, and share 'iColspan' between the two TD elements? One other little thing, it's a good idea to create the ggSpan element outside of the if statement, since you are using it in the 'else'. I think it is okay here due to the loop - but it might be possible for the 'else' to happen before the variable is created in other code.
Replies
I'm not entirely sure what you mean I'm afraid. What do you mean by a "row group"? The only add data function (off the top of my head) is this one: http://datatables.net/examples/api/add_row.html . It should be possible to integrate this with the row grouping example, just by adding the required data.
Regards,
Allan
thanks
Regards,
Allan
not want to add rows ... in the grouped row with in past initialization I want add a sum of values.
example:
row_1 : X ; Tom ; 6
row_2 : X ; Tim ; 17
row_3 : X ; Jhon; 11
row_4 : Y ; Paky ; 5
after group rows I want on same group TR
=> X [34]
Tom
Tim
Jhon
=> Y [ 5 ]
Paky
Yes, no reason why that shouldn't be possible. When you are looping for the rows to look for the groups and then add the new TR/TD element for the group, why not just total up the information and add it in there (i.e. in fnDrawCallback).
Allan
I'm not inclined to just bash out code (since nobody learns that way, including me!), but hopefully I can point you in the right direction.
In the fnDrawCallback function you have, you are looping over the TR elements in the table, checked on each loop to see if there is a new "group" required. It is trivial to modify this to add up the totals for each group - so I would suggest starting there (just getting the value from the DOM and adding it to a variable) and either alert() or console.log() that. Once that is going, you just need to enter your calculated value into the group row you created - again DOM methods will let you do this.
Give it a go and see what happens :-)
Allan
here my code:
[code]
var i=0;
for ( var i=0 ; i
Looks good. So the issue now is just colspan etc is it? The nCell variable always uses colspan, so perhap you can just modify that, and share 'iColspan' between the two TD elements? One other little thing, it's a good idea to create the ggSpan element outside of the if statement, since you are using it in the 'else'. I think it is okay here due to the loop - but it might be possible for the 'else' to happen before the variable is created in other code.
Regards,
Allan
If my iColspan = 4 , I would have two cells with colspan = 2
thanks allan for all the advice !!! ;)
I think you are along the right lines there - does something like this not work:
[code]
var nGroup = document.createElement( 'tr' );
var nCell = document.createElement( 'td' );
var ggSpan=document.createElement( 'td' );
nCell.colSpan = iColspan-2;
ggSpan.colSpan = 2;
[/code]
Regards,
Allan