Combination of manipulation of selectable values and language destroys default value in search field

Combination of manipulation of selectable values and language destroys default value in search field

RoloTomasiRoloTomasi Posts: 18Questions: 9Answers: 0

Hi all,

I want to manipualte the default value of the search field AND use german language.

This could be the mechanism for default value

        $('#example').DataTable( {
                lengthMenu: [ [ -1, 10  ], ["Alle", 10] ]
        } );

and this one for the language

    $('#example').DataTable( {
        language: {
          lengthMenu: "_MENU_ Einträge",
        }
    } );

But: How do I combine them?

This suggestion at https://datatables.net/reference/option/language.lengthMenu is quite a good solution.

$('#example').dataTable( {
  "language": {
    "lengthMenu": 'Zeige <select>'+
      '<option value="-1">Alle</option>'+   
      '<option value="10">10</option>'+
      '</select> Eintraege'
  }
} );    

But it destroys the default value, which I want to see as "Alle". It always shows "10".

Can anyone help for getting the default value?

Thanks it advance.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921
    Answer ✓

    Maybe i'm not understanding the problem but it seems like the combination of the two works here:
    http://live.datatables.net/zurodopu/1/edit

    Kevin

  • RoloTomasiRoloTomasi Posts: 18Questions: 9Answers: 0

    Hi kthorngren,

    thank you, that's it. And I got it myself. This one works for me.

    $('#example').DataTable( 
       {
        lengthMenu: [ [ -1, 10], ["Alle", 10] ],
    
        language: {
            lengthMenu : '<select>'+
                         '<option value="10">10</option>'+
                         '<option value="-1">Alle</option>'+
                         '</select> Eintr&auml;ge'
                       }
      }
    ); 
    

    Rolo

This discussion has been closed.