can't get data from row
can't get data from row
chucke1992
Posts: 8Questions: 0Answers: 0
When I click on a row - I add class info to it.
[code]$("#roletable tbody").click(function(event) {
$(oTable2.fnSettings().aoData).each(function() {
$(this.nTr).removeClass('info');
});
$(event.target.parentNode).addClass('info');
});
[/code]
I want to pass values from selected row(it is always only one row) to modal form when I click on [quote]rolesedit[/quote] button.
I was trying to do like this(I check each row and in order to check data I show alert)
[code]$("#rolesedit").click(function() {
var arr = oTable1.fnGetNodes();
var item = null;
for(var i = 0; i < arr.length; i++) {
if ($(arr[i]).hasClass('info')){
item = oTable1.fnGetData(arr[i]);
alert(item[0]);
}
}
$('#ErolenameInput').val(item[0]);
$('#ERoleID').val(item[1]);
});
[/code]
But item[0] is always undefined.
I was trying something like this too
[code]
$(oTable1.fnSettings().aoData).each(function() {
if ($(this.nTr).hasClass('info'))
alert('has class' + oTable1.fnGetData(this.nTr)[0]);
});[/code]
but it undefined too.
What is the correct way to get data?
[code]$("#roletable tbody").click(function(event) {
$(oTable2.fnSettings().aoData).each(function() {
$(this.nTr).removeClass('info');
});
$(event.target.parentNode).addClass('info');
});
[/code]
I want to pass values from selected row(it is always only one row) to modal form when I click on [quote]rolesedit[/quote] button.
I was trying to do like this(I check each row and in order to check data I show alert)
[code]$("#rolesedit").click(function() {
var arr = oTable1.fnGetNodes();
var item = null;
for(var i = 0; i < arr.length; i++) {
if ($(arr[i]).hasClass('info')){
item = oTable1.fnGetData(arr[i]);
alert(item[0]);
}
}
$('#ErolenameInput').val(item[0]);
$('#ERoleID').val(item[1]);
});
[/code]
But item[0] is always undefined.
I was trying something like this too
[code]
$(oTable1.fnSettings().aoData).each(function() {
if ($(this.nTr).hasClass('info'))
alert('has class' + oTable1.fnGetData(this.nTr)[0]);
});[/code]
but it undefined too.
What is the correct way to get data?
This discussion has been closed.
Replies
Your second clock block looks more correct. `item[0]` will be undefined if you are using an object data source. Are you?
Allan
Yes, I use ajax data source - response from server in json with serialized to json object using GSON.
Allan
Oh. I see. Thanks.