Editor datatable field type events - Need Help on How to address the field
Editor datatable field type events - Need Help on How to address the field
paul@dmcreative.com
Posts: 27Questions: 5Answers: 0
in Editor
I want to monitor the select and deselect events of an editor datatable field.
Reference is made to use the editor.field('name').dt() function to access the api.
Could someone please post the correct format to do this.
Assuming the following javascipt code what would be used at ??? so that the users.site field select event is being monitored
<?php
??.on('select' function() {
alert('Row Selected');
} );
```
?>
``` javascript
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: "../php/join.php",
table: "#example",
fields: [ {
label: "First name:",
name: "users.first_name"
}, {
label: "Last name:",
name: "users.last_name"
}, {
label: "Phone #:",
name: "users.phone"
}, {
label: "Site:",
name: "users.site",
type: "datatable",
}
]
} );
$('#example').DataTable( {
dom: "Bfrtip",
ajax: {
url: "../php/join.php",
type: 'POST'
},
columns: [
{ data: "users.first_name" },
{ data: "users.last_name" },
{ data: "users.phone" },
{ data: "sites.name" }
],
select: true,
buttons: [
{ extend: "create", editor: editor },
{ extend: "edit", editor: editor },
{ extend: "remove", editor: editor }
]
} );
} );
This discussion has been closed.
Replies
You would use a DataTables API instance for that, so something like this: http://live.datatables.net/wayemiwe/1/edit
Colin
Colin,
You missed my question. I am asking about events in a datatable embedded in an editor form, NOT a normal standalone table.
Please look at the sample javascript I referenced, and at the editor definition for users.site. It is users.site that I am trying to get to the select event.
Thank you
Paul
Hi Paul,
You can use the
field().dt()
method of thedatatable
field type to get the DataTable instance (it appears I forgot to add that into the docs - apologies, will add now):Allan
Allan
Exactly the information that I was looking for.
Thank You
Paul