button value
button value
yskapell
Posts: 47Questions: 14Answers: 3
Hello all,
I have this code on a button
{
text: "Copy",
action: function ( e, dt, node, config ) {
var tblData = this.rows('.selected').data();
//console.log(tblData);
var tmpData;
$.each(tblData, function(i, val) {
tmpData = tblData[i];
count = count + 1;
$.post('copy.php', {
data: tmpData
}, function(response) {
//$('#content').html(response);
console.log(response);
});
});
return totalCount = count;
}
},
Can I pass the totalCount in another button ?
for examples to have something like this
{
text: "Preiview ("+totalCount+")",
...
}
This question has an accepted answers - jump to answer
Answers
Yep, set a global variable and update the other buttons text on click of the first button.
I want to update with the row I select to copy..
Sounds like you want to change the button text. To do this use
button().text()
.I'm not sure what this means. Please elaborate.
Kevin
If I copy 5 rows the Preview button to change to Preview (5), if I copy 1 to change Preview (1) etc
Maybe something like this:
I didn't test this. First it gets the selected rows. Uses
count()
to get the row count to set the other button viabutton().text()
. Replacex
with the appropriatebutton-selector
.Does your
copy.php
accept multiple rows? If so you can send them in one request. Changevar tblData = rows.data();
tovar tblData = rows.data().toArray();
to get a Javascript array that can be sent.Kevin