oLanguage feature hides extra toolbar

oLanguage feature hides extra toolbar

John_HJohn_H Posts: 5Questions: 0Answers: 0
edited May 2012 in Bug reports
This is my first posting, so let me start with saying what a fantastic piece of software datatables is!

I have a table with a extra toolbar created like this:
[code]"sDom": 'fr<"#tabletoolbar">ltpi'[/code]
and
[code]$("#tabletoolbar").html(
'AddDelete'
);[/code]
Works great!
However, when I add this:
[code]"oLanguage": { "sUrl": "/public/i18/datatables.dutch.txt" }[/code]
the toolbar is stil drawn (i have a red border around it), but the buttons do not show anymore.

I am using the latest version of Datatables.

Thanks.

Replies

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Try putting your $().html() manipulation into fnInitComplete . The reason for this is that the features aren't rendered until the language is loaded (otherwise they wouldn't have the language information available!).

    Allan
  • John_HJohn_H Posts: 5Questions: 0Answers: 0
    That fixed my problem,

    Thanks!
  • John_HJohn_H Posts: 5Questions: 0Answers: 0
    Hmm .. all the manipulation has te be inside fnInitComplete now.

    like this:
    [code]"fnInitComplete": function(oSettings, json) {
    $("#tabletoolbar").html('AddDelete');
    $('#DeleteButton').attr('disabled', 'disabled');
    $('#AddButton').button().click(function() { $("#dialog-form").dialog("open"); });
    $('#DeleteButton').click( function() {
    var anSelected = fnGetSelected( oTable );
    var id = anSelected[0].getAttribute('id');
    deleteRowServer(id, oTable);
    } );
    }[/code]

    quite messy, any thoughts on this?
  • John_HJohn_H Posts: 5Questions: 0Answers: 0
    edited May 2012
    And there is another side effect, consider:
    [code]

    "bServerSide": true,
    "sAjaxSource": "/admin/getledger",
    "fnServerParams": function ( aoData ) {
    aoData.push( { "name": "ledger_hasdata", "value": $('#ledgerdata').is(":checked") })

    [/code]

    in combination with

    [code]

    "fnInitComplete": function(oSettings, json) {
    $("#tabletoolbar").html('Alleen bedragen: ');
    $('#ledgerdata').click( function() {
    oTable.fnDraw();
    });
    }

    [/code]

    The request to the server is made before the checkbox is drawn in state checked ..
  • John_HJohn_H Posts: 5Questions: 0Answers: 0
    This is what I came up with:

    [code]
    "fnInitComplete": function(oSettings, json) {
    $('#placeholder').prependTo($('#tabletoolbar'));
    }
    [/code]

    And somwhere on my page:

    [code]


    Alleen bedragen:


    [/code]

    Now, everything can stay as it was, and when the datatable is ready, the toolbar is moved into place.

    Thanks for the help.

    John
This discussion has been closed.