将语言更改为德语

时间:2016-02-02 18:01:37

标签: datatables yadcf

我尝试使用yadcf数据库JS。它运行,但我无法将语言更改为德语。

我试过了:

$(document).ready(function(){
       var oTable = $('#history_table').DataTable({
            "sScrollY": "100px",
            "iDisplayLength": 5,
            "bJQueryUI": true,
            "bStateSave": true,
            "language": {
                "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
            }

        }).yadcf([
            {column_number : 0, filter_default_label: "Datum", sort_order: "asc"},
            {column_number : 1, filter_default_label: "wer", sort_order: "desc"},
            {column_number : 2, filter_default_label: "bei wem"},
            {column_number : 3, filter_default_label: "wo"},
            {column_number : 4, filter_default_label: "was"},
            {column_number : 5, filter_default_label: "Wert alt"},
            {column_number : 6, filter_default_label: "Wert neu"}]);
}

1 个答案:

答案 0 :(得分:0)

使用数据表的大写 D api时,您必须使用yadcf.init而非.yadcf调用,如此(see demo

$(document).ready(function() {

       var oTable = $('#table_1').DataTable({
            "sScrollY": "100px",
            "iDisplayLength": 5,
            "bJQueryUI": true,
            "bStateSave": true/*,
            "language": {
                "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
            }*/

        });
        yadcf.init(oTable, [
            {column_number : 0, filter_default_label: "Datum", sort_order: "asc"},
            {column_number : 1, filter_default_label: "wer", sort_order: "desc"},
            {column_number : 2, filter_default_label: "bei wem"},
            {column_number : 3, filter_default_label: "wo"}]);
});

但是,似乎我在yadcf a.t.m中遇到了问题,我需要修复它,以便在languageurl获取json时使用过滤器,

同时你可以将语言json放入数据表构造函数中,它可以正常工作,see demo

$(document).ready(function() {

       var oTable = $('#table_1').DataTable({
            "sScrollY": "100px",
            "iDisplayLength": 5,
            "bJQueryUI": true,
            "bStateSave": true,
            "language": {
              "sEmptyTable":    "Keine Daten in der Tabelle vorhanden",
              "sInfo":          "_START_ bis _END_ von _TOTAL_ Einträgen",
              "sInfoEmpty":     "0 bis 0 von 0 Einträgen",
              "sInfoFiltered":  "(gefiltert von _MAX_ Einträgen)",
              "sInfoPostFix":   "",
              "sInfoThousands":     ".",
              "sLengthMenu":    "_MENU_ Einträge anzeigen",
              "sLoadingRecords":    "Wird geladen...",
              "sProcessing":    "Bitte warten...",
              "sSearch":        "Suchen",
              "sZeroRecords":   "Keine Einträge vorhanden.",
              "oPaginate": {
                "sFirst":       "Erste",
                "sPrevious":    "Zurück",
                "sNext":        "Nächste",
                "sLast":        "Letzte"
              },
              "oAria": {
                "sSortAscending":  ": aktivieren, um Spalte aufsteigend zu sortieren",
                "sSortDescending": ": aktivieren, um Spalte absteigend zu sortieren"
              }
            }


        });
        yadcf.init(oTable, [
            {column_number : 0, filter_default_label: "Datum", sort_order: "asc"},
            {column_number : 1, filter_default_label: "wer", sort_order: "desc"},
            {column_number : 2, filter_default_label: "bei wem"},
            {column_number : 3, filter_default_label: "wo"}]);
    });