UniqueData
asked on
get cell value in dataTable
I am using datatable.net plugin. i need to get the value of data that is in the dataset but not displayed in the grid (if that matters). I have tried several things but can't get it to work.
var tableTools = new $.fn.dataTable.TableTools(table, {
sRowSelect: "os",
aButtons: [
{
sExtends: 'select_single',
sButtonClass: 'marginLeft',
sButtonText: 'View History',
editor: editor,
fnClick: function () {
//window.location.href = 'grid_staffHistory.php';
//alert( 'Row index: '+table.row( '.selected' ).index() );
alert( 'primary key: '+table.row( '.selected' ).cell('usertable.uuk').data() );
//alert( 'Row index: '+ editor.get('usertable.uuk') );
}
},
{
sExtends: 'select_single',
sButtonClass: 'marginLeft',
sButtonText: 'Add New Staff',
fnClick: function () {
window.location.href = 'addUsers.php';
}
}
]
} );
$( tableTools.fnContainer() ).insertBefore( '#table_filter' );
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
your answer let me down the right path. When I defined the editor I needed to include that field, but as hidden. Then, one of the lines I had commented out would work.
then...
editor = new $.fn.dataTable.Editor( {
serverSide: true,
ajax: "lib/getdata.php",
table: "#table",
idSrc: "usertable.uuk",
fields: [
{
name: "usertable.uuk",
visible: "false"
},
//rest of visible fields here
then...
var tableTools = new $.fn.dataTable.TableTools( table, {
sRowSelect: "os",
aButtons: [
{
sExtends: 'select_single',
sButtonClass: 'marginLeft',
sButtonText: 'View History',
editor: editor,
fnClick: function () {
//window.location.href = 'grid_staffHistory.php';
alert( 'Row identifier: '+ editor.get('usertable.uuk') );
}
},
ASKER
Thank you for getting me on the right path :)
Open in new window
I created a datatable example from the zero config for you http://jsbin.com/pacaguyuzNote the first column on the first row has the data- attribute.
Open in new window
I used the code below to get it
Open in new window
Give the sample a try and let me know if that is what you are trying to do