Accessing HTML Objects value property within a DataTable using a button
Accessing HTML Objects value property within a DataTable using a button
jcarver
Posts: 1Questions: 1Answers: 0
I am having trouble accessing an HTML Objects value property while the Object is with in a DataTable by clicking a button.
When I click a "Save Test" Button in the last column of a table on a particular row, I want to grab the content of that row to include the HTML Objects value. (eg. inputbox) The code below is how I am doing it now, and it works. However, when filtering is applied or paging is applied it does not work correctly. Any help would be appreciated.
$("#manage_test_definitions").on('click', '#saveTest',
function ()
{
// Create instance of the table
var oTable = $('#manage_test_definitions').dataTable();
// Get the Row Index
var row = $(this).closest('tr');
var rowindex = row.index();
// Retrieve Data out of the row
var testSuiteVersionID = $("#TestSuiteVersionID").html();
var testId = oTable.fnGetData(rowindex)[0];
var dataType = oTable.fnGetData(rowindex)[2];
var LowerLimit = row.find('.LowerLimit').val();
var UpperLimit = row.find('.UpperLimit').val();
var Comparison = row.find('.Comparison').val();
var Unit = row.find('.Unit').val();
// Determine if we are using double or boolean process data acorrdingly.
if(dataType == "Double")
{
// Prepare data packet to send to PHP
var data = testSuiteVersionID
var data = data + ",";
var data = data + testId;
var data = data + ",";
var data = data + dataType;
var data = data + ",";
var data = data + LowerLimit;
var data = data + ",";
var data = data + UpperLimit;
var data = data + ",";
var data = data + Comparison;
var data = data + ",";
var data = data + Unit;
// Add Double Test
SaveDoubleTest(testId, data, rowindex);
}
else
{
// Prepare data packet to send to PHP
var data = testSuiteVersionID
var data = data + ",";
var data = data + testId;
var data = data + ",";
var data = data + dataType;
var data = data + ",";
var data = data + Comparison;
// Add Boolean Test
SaveBooleanTest(testId, data, rowindex);
}
});
This discussion has been closed.
Answers
Why are you redeclaring
data
like 40 times?... lol. You could just concat one longer string..Is there a way I can replicate this? If not, try to re-create it on live.datatables.net, im sure I can fix it, im just having a hard time understanding what the issue is, why does pagination/filtering break it?