getting string out of row().data( )
getting string out of row().data( )
Hi guys,
Instead of clicking cell one by one with cell().data
Is there a way to get the list of string out of row().data ?
I read from that forum that the Row() is Object Data.
And when I try to
$('#example1 tbody').on( 'click', 'td', function () {
var allrow = table.row(this).data();
alert( allrow );
} );
The alert show the row that I clicked like thisRowCell1,thisRowCell2,hellworld
all separated with ","
I tried to split the text using "," and I still fail.
I do not want to go all the way using ID, Ajax to handle this. (because I'm very new to programming)
I simply, just want to be able to click certain row and that
thisRowCell1
is pasted in other target (#id)
while thisRowCell2
show in another target. (#id)
Thank you in advance !
Answers
This will return object based data if you are using
columns.data
. Based on your description you are not usingcolumns.data
since its returning an array.You don't need to do this since its already an array.
Since the
allrow
is an array you would access the first element withvar thisRowCell1 = allrow[0]
.Kevin
oh Kevin, you save my daysssss.
Thank you so much for clear explanation and examples.
I tried something like
alert(allowrow[0]);
before but it didn't worklittle that I know, I have to
var thisRowCell1 = allrow[0]
and thenalert(thisRowCell1);
now everything works just fine. I love it so much !!
Thank you so so so much.
Hmm - that doesn't sound right.
alert(allrow[0])
is exactly the same asvar thisRowCell1 = allrow[0]; alert(thisRowCell1);
.I'd need to see an example of both causing the different behaviour to be able to explain that though.
Allan