access aaData on row click
access aaData on row click
dsridhar10
Posts: 5Questions: 0Answers: 0
Hi,
I am using a datatable to display the data from two dimensional array. The data (company, empno, employee name and status) and the column definitions are as follows
[code]
var data = [["ABC", "1", "Employee 1", "W"],
["ABC", "2", "Employee 2", "C"],
["ABC", "3", "Employee 3", "C"]];
$('mytable').datatable({"aoColumns": [{
"sTitle": "Submitted
Enrolled",
"bSortable": false,
"sClass": "status",
"fnRender": function(obj) {
status = obj.aData[ 3 ];
switch (status) {
case "W": //waiting
src1 = myObject.ImageRegLightUrl;
alt1 = 'Waiting';
src2 = myObject.ImageRegLightUrl;
alt2 = 'Not pushed to the live tables';
break;
case "C": //submitted but not pushed to the live tables.
src1 = myObject.ImageGreenLightUrl;
alt1 = 'Completed';
src2 = myObject.ImageRegLightUrl;
alt2 = 'Submitted but not pushed to the live tables';
break;
case "E": //submitted and pushed to the live tables.
src1 = myObject.ImageGreenLightUrl;
alt1 = 'Completed';
src2 = myObject.ImageGreenLightUrl;
alt2 = 'Submitted and pushed to the live tables';
break;
}
return '' + ' ' + '';
}
},
{
"bSortable": true,
"sTitle": "Employee",
"fnRender": function(obj) {
return '' + obj.aData[ 2 ] + ''
}
},
{
"sTitle": "",
"bSortable": false,
"fnRender": function(obj) {
src1 = myObject.ImageDetailsUrl;
alt1 = 'Details';
return '';
}
},
{
"sTitle": "",
"bSortable": false,
"fnRender": function(obj) {
return '';
}
},
{
"sTitle": "",
"bSortable": false,
"fnRender": function(obj) {
return '';
}
}]});
[/code]
As you can see, I have not defined a separate column for each element in the data array. This is causing problem when retrieving data.
When the user clicks on one of the buttons, I would like to retrieve the data associated with that row. For example, if the user clicks on row 0, I need to access the array ["ABC", "1", "Employee 1", "W"]. How would I do that? If I use fnGetData(), I get the rendered html data even if I set "bUseRendered" : false.
I am using a datatable to display the data from two dimensional array. The data (company, empno, employee name and status) and the column definitions are as follows
[code]
var data = [["ABC", "1", "Employee 1", "W"],
["ABC", "2", "Employee 2", "C"],
["ABC", "3", "Employee 3", "C"]];
$('mytable').datatable({"aoColumns": [{
"sTitle": "Submitted
Enrolled",
"bSortable": false,
"sClass": "status",
"fnRender": function(obj) {
status = obj.aData[ 3 ];
switch (status) {
case "W": //waiting
src1 = myObject.ImageRegLightUrl;
alt1 = 'Waiting';
src2 = myObject.ImageRegLightUrl;
alt2 = 'Not pushed to the live tables';
break;
case "C": //submitted but not pushed to the live tables.
src1 = myObject.ImageGreenLightUrl;
alt1 = 'Completed';
src2 = myObject.ImageRegLightUrl;
alt2 = 'Submitted but not pushed to the live tables';
break;
case "E": //submitted and pushed to the live tables.
src1 = myObject.ImageGreenLightUrl;
alt1 = 'Completed';
src2 = myObject.ImageGreenLightUrl;
alt2 = 'Submitted and pushed to the live tables';
break;
}
return '' + ' ' + '';
}
},
{
"bSortable": true,
"sTitle": "Employee",
"fnRender": function(obj) {
return '' + obj.aData[ 2 ] + ''
}
},
{
"sTitle": "",
"bSortable": false,
"fnRender": function(obj) {
src1 = myObject.ImageDetailsUrl;
alt1 = 'Details';
return '';
}
},
{
"sTitle": "",
"bSortable": false,
"fnRender": function(obj) {
return '';
}
},
{
"sTitle": "",
"bSortable": false,
"fnRender": function(obj) {
return '';
}
}]});
[/code]
As you can see, I have not defined a separate column for each element in the data array. This is causing problem when retrieving data.
When the user clicks on one of the buttons, I would like to retrieve the data associated with that row. For example, if the user clicks on row 0, I need to access the array ["ABC", "1", "Employee 1", "W"]. How would I do that? If I use fnGetData(), I get the rendered html data even if I set "bUseRendered" : false.
This discussion has been closed.