Giving buttons an ID

Giving buttons an ID

xtremer360xtremer360 Posts: 84Questions: 2Answers: 0
edited July 2012 in General
I'm using the TableTools plugin and tryign to figure out how I can assign a class or id with any of my buttons.

Current Code
[code]
$( '#titles-table' ).dataTable({
"sDom": '<"top"lTf<"clear">>rt<"actions"<"actions-left"i><"actions-right"p>>',
"bAutoWidth": false,
"sPaginationType" : "full_numbers",
"oTableTools": {
"aButtons": [
{
"sExtends": "text",
"sButtonText": "Add"
},
{
"sExtends": "text",
"sButtonText": "Edit"
},
{
"sExtends": "text",
"sButtonText": "Delete"
},
]
},
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] },
{ "sWidth": "20px", "aTargets": [ 0 ] },
{ "sWidth": "40px", "aTargets": [ 1 ] },
{ "sClass": "alignCenter", "aTargets": [ 1 ] }
]
});
[/code]

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    You can't currently give them an ID (not a bad idea for a future enhancement), but you can give them a class with the sButtonClass option: http://datatables.net/extras/tabletools/button_options#sButtonClass

    Allan
  • xtremer360xtremer360 Posts: 84Questions: 2Answers: 0
    Here's the part that confuses me though on doing ajax requests.

    [code]
    $( '#table' ).dataTable({
    "sDom": '<"top"lTf<"clear">>rt<"actions"<"actions-left"i><"actions-right"p>>',
    "bAutoWidth": false,
    "sPaginationType" : "full_numbers",
    "oTableTools": {
    "aButtons": [
    {
    "sExtends": "text",
    "sButtonText": "Add"
    },
    {
    "sExtends": "text",
    "sButtonText": "Edit"
    },
    {
    "sExtends": "text",
    "sButtonText": "Delete",
    "sButtonClass": "delete"
    },
    ]
    },
    "aoColumnDefs": [
    { "bSortable": false, "aTargets": [ 0 ] },
    { "sWidth": "20px", "aTargets": [ 0 ] },
    { "sWidth": "40px", "aTargets": [ 1 ] },
    { "sClass": "alignCenter", "aTargets": [ 1 ] }
    ]
    });

    <?php
    $tmpl = array ( 'table_open' => '' );
    $data = array('name' => 'titles', 'class' => 'selectall');
    $this->table->set_heading(form_checkbox($data), 'ID', 'Title Name', 'Style', 'Status');
    $this->table->set_template($tmpl);
    foreach ($titles as $row)
    {
    $checkbox_data = array(
    'name' => 'titles',
    'id' => $row->id
    );
    $this->table->add_row(form_checkbox($checkbox_data), $row->id, $row->title_name, $row->type_name, $row->status_name);
    }
    echo $this->table->generate();
    ?>

    [/code]
This discussion has been closed.