// Only allow a new row when not currently editing
if ( nEditing !== null ) {
return;
}
oTable.fnUpdate( aData[i], nRow, i, false );, getting data from row
var aData = oTable.fnGetData(nRow);returns null
<cfif isdefined("form.hdnaction")>
<cfoutput>
<script type="text/javascript" language="javascript">
alert("hdnaction exists = #form.hdnaction#");
</script>
<cfif form.hdnaction neq "display">
<p>
Action #form.hdnaction#<br>
Dealer #form.hdndlr#<br>
Name #form.hdnname#<br>
Address #form.hdnsddr#<br>
Location #form.hdnloc#<br>
Postcode #form.hdnpcode#<br>
State #form.hdnstate#<br>
Country #form.hdnctry#<br>
Phone #form.hdnphone#
</p>
</cfif>
</cfoutput>
</cfif>
<body>
<form name="aa_TestEdit" id="aa_TestEdit" action="aa_TestEdit.cfm" method = "post">
<!--- some variables to apply any edits --->
<input type="hidden" ame ="hdnaction" id="hdnaction" value=''>
<input type="hidden" ame ="hdndlr" id="hdndlr" value=''>
<input type="hidden" ame ="hdnname" id="hdnname" value=''>
<input type="hidden" ame ="hdnaddr" id="hdnaddr" value=''>
<input type="hidden" ame ="hdnloc" id="hdnloc" value=''>
<input type="hidden" ame ="hdnpcode" id="hdnpcode" value=''>
<input type="hidden" ame ="hdnstate" id="hdnstate" value=''>
<input type="hidden" ame ="hdnctry" id="hdnctry" value=''>
<input type="hidden" ame ="hdnphone" id="hdnphone" value=''>
This is looking to see if there is a form, and a form element called hdnaction. Initially it won't find one, but I expect it should once we submit the form.
$('#dealers a.delete').live('click', function (e) {
e.preventDefault();
var nRow = $(this).parents('tr')[0];
oTable.fnDeleteRow( nRow );
document.aa_TestEdit.hdnaction.value = "delete";
} );
$('#dealers a.edit').live('click', function (e) {
e.preventDefault();
/* Get the row as a parent of the link that was clicked on */
var nRow = $(this).parents('tr')[0];
if ( nEditing !== null && nEditing != nRow ) {
/* Currently editing - but not this row - restore the old before continuing to edit mode */
restoreRow( oTable, nEditing );
editRow( oTable, nRow );
document.aa_TestEdit.hdnaction.value = "edit";
nEditing = nRow;
}
else if ( nEditing == nRow && this.innerHTML == "Save" ) {
/* Editing this row and want to save it */
saveRow( oTable, nEditing );
nEditing = null;
}
else {
/* No edit in progress - let's start one */
editRow( oTable, nRow );
document.aa_TestEdit.hdnaction.value = "edit";
nEditing = nRow;
}
} );
As you can see, I set the hdnaction input to indicate what action is to be taken when we submit the form.
function updatedata(aData){
document.aa_TestEdit.hdndlr.value = aData[0];
document.aa_TestEdit.hdnname.value = aData[1];
document.aa_TestEdit.hdnaddr.value = aData[2];
document.aa_TestEdit.hdnloc.value = aData[3];
document.aa_TestEdit.hdnpcode.value = aData[4];
document.aa_TestEdit.hdnstate.value = aData[5];
document.aa_TestEdit.hdnctry.value = aData[6];
document.aa_TestEdit.hdnphone.value = aData[7];
document.getElementById("aa_TestEdit").submit();
}
Notice the submit(). This does do a submit, but the server doesn't see the form, so doesn't know what to do. Once this is working correctly, I intend to replace the displays of the data with either Delete, or Insert/Update, as appropriate, before reloading the page with the new data.
"aoColumns": [
{"fnRender": function(oObj)
{
return '<td class="update"><a href="#" class="edit"><i class="cus-application-form-edit" rel="tooltip" data-placement="left" title="Edit"></i></a></td>';
}
}
]
oObj.aData[8] = '<td class="update"><a href="#" class="edit"><i class="cus-application-form-edit" rel="tooltip" data-placement="left" title="Edit"></i></a></td>';
return oObj.aData[8];
aoColumnDefs: [
{
"aTargets":[12], // Assuming you want your link / button / action to be here
"fnCreatedCell": function(nTd, sData, oData, iRow, iCol)
{
$(nTd).css('text-align', 'center');
},
"mData": null,
"mRender": function( data, type, full) {
return '<td><a href="#" class="reject"><i class="aug-delete" rel="tooltip" data-placement="right" title="Reject"></i></a></td>';
}
}
]
It looks like you're new here. If you want to get involved, click one of these buttons!
Get useful and friendly help straight from the source.