For only rows selectioned
For only rows selectioned
antoniocib
Posts: 277Questions: 62Answers: 1
footerCallback: function ( row, data, start, end, display ) { // SOMMA PER PEDANE
var api = this.api(), data;
var intVal = function ( i ) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
// Total over this page
pageTotal = api
.column( 7, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer
$( api.column( 7 ).footer() ).html(
pageTotal
);
pageTotal = api
.column( 8, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer
$( api.column( 8 ).footer() ).html(
pageTotal
);
pageTotal = api
.column( 9, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer
$( api.column( 9 ).footer() ).html(
pageTotal
);
},
I need to visualize the sums of only rows selected,what i need to add at code for do it?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
This thread is asking a similar question. See if it helps.
Kevin
In this way?
The
selector-modifier
docs show the options. In the examples it shows combining the options in one object, like this{ page: 'current', selected: 'true'}
. You have them as two objects.Kevin
http://damoratraffico.netsons.org/web/scrivania1.html
Look this,mhh doesnt work..
Sorry, my mistake. When selecting rows using
column(9, {selected: true})
doesn't work. Allan explains in this thread. You will need to use the technique he shows. I put it into an example here:http://live.datatables.net/tofavepa/1/edit
Note also the use of the
select
anddeselect
events. It usesdraw()
to draw the table each time the selection changes.Kevin
@kthorngren for add a column with a selectbox?How i need to do?
I don't understand the question. Does the example I provided not work in your page?
Kevin
Yes ur example works, but for select more rows i need to press Ctrl if i add a select-checkbox i bypass this problem understand look this photo:
https://datatables.net/forums/uploads/editor/xm/2fodawm647hs.png
Still don't understand what the question is. If you want to change how the selection works use
select.style
.Kevin
https://editor.datatables.net/examples/bubble-editing/simple.html
look in this example the first column
if i add this in my js:
return an error, Cannot read property 'style' of undefined
Generally this means the number of HTML columns doesn't match the number of Datatables columns. Did you add an extra column in your HTML to for the checkbox?
Kevin
No Kevin