How to get a value from a row on edit
How to get a value from a row on edit
I am trying to dynamically update a select box.
[code]
editor.on('onInitEdit', function () {
alert (editor.get('userid');
$(editor.field('caseinfo.agencyid').update(agencyloader()));
$(editor.field('userid').update(userloader(editor.get('caseinfo.agencyid'))));
} );
[/code]
The problem is I am getting defaults from the editor form. and not values in the row. How would I get the values from the row for the edit event?
I have the alart just to see what I was getting?
[code]
editor.on('onInitEdit', function () {
alert (editor.get('userid');
$(editor.field('caseinfo.agencyid').update(agencyloader()));
$(editor.field('userid').update(userloader(editor.get('caseinfo.agencyid'))));
} );
[/code]
The problem is I am getting defaults from the editor form. and not values in the row. How would I get the values from the row for the edit event?
I have the alart just to see what I was getting?
This discussion has been closed.
Replies
Having said that - is `editor.get('caseinfo.agencyid')` giving you the default? That shouldn't be the case. The values are set before onInitEdit is executed.
Regards,
Allan
[code]
editor.on('onInitEdit', function () {
oTable = $('#caseinfo').dataTable();
var sData = oTable.fnGetData.editrow;
alert( 'The cell clicked on had the value of '+sData[0] );
} );
[/code]
I don't really get it. Sorry I haven't quite wrapped my mind around the datatables framework, but am getting closer?
Thanks
[code]
editor.on('onInitEdit', function () {
oTable = $('#caseinfo').dataTable();
var sData = oTable.$('tr').fnGetData(this.s.editrow);
alert( 'The cell clicked on had the value of '+sData[0] );
} );
[/code]
[code]
editor.on('onInitEdit', function () {
oTable = $('#caseinfo').dataTable();
var sData = oTable.fnGetData(this.s.editRow);
alert( 'The cell clicked on had the value of '+sData[0] );
} );
[/code]
Allan
The cell clicked on had the value of undefined
[code]
(function($){
$(document).ready(function() {
var editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "php/table.agencies.php",
"domTable": "#agencies",
"fields": [
{
"label": "Agency Name",
"name": "agencyname",
"type": "text"
},
{
"label": "Address",
"name": "agencyaddress",
"type": "text"
},
{
"label": "City",
"name": "agencycity",
"type": "text"
},
{
"label": "State",
"name": "agencystate",
"type": "text"
},
{
"label": "Zip",
"name": "agencyzip",
"type": "text"
},
{
"label": "Phone",
"name": "agencyphone",
"type": "text"
},
{
"label": "Notes",
"name": "agencynotes",
"type": "text"
}
]
} );
editor.on('onInitEdit', function () {
oTable = $('#agencies').dataTable();
var sData = oTable.fnGetData(this.s.editRow);
alert( 'The cell clicked on had the value of '+sData[1] );
} );
$('#agencies').dataTable( {
"sDom": "Tfrtip",
"sAjaxSource": "php/table.agencies.php",
"aoColumns": [
{
"mData": "agencyname"
},
{
"mData": "agencyaddress"
},
{
"mData": "agencycity"
},
{
"mData": "agencystate"
},
{
"mData": "agencyzip"
},
{
"mData": "agencyphone"
},
{
"mData": "agencynotes"
}
],
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]
}
} );
} );
}(jQuery));
[/code]
sData[1] is undefined. Do you mean `sData.agencyaddress` ? It is an object that you have in your data source (based upon your DataTables initialisation), not an array.
Allan