Datatable Language

Datatable Language

genesisrgenesisr Posts: 15Questions: 6Answers: 0

Hello.

I want to know If it's possible to put in "language" a variable from javascript. I mean:

"language":{

"sInfoPostFix": "",
"sSearch": ** $rootScope.var** ,
"sUrl": "",
}

or language just receive strings?

This question has an accepted answers - jump to answer

Answers

  • genesisrgenesisr Posts: 15Questions: 6Answers: 0

    my page contains two languages, so I want to know if I can put a dynamic var. depending on the language user wants to see.

  • allanallan Posts: 63,210Questions: 1Answers: 10,415 Site admin
    Answer ✓

    If your variable contains a string, then yes, sure you can do that: http://live.datatables.net/fisohisa/1/edit

    Allan

  • genesisrgenesisr Posts: 15Questions: 6Answers: 0
    edited May 2020

    thanks!

    The fact is that I have a method that calls a rest service in java which selects the language by "labels" in a file.properties (With all the labels in spanish or english).

    I call the method in this way

    $scope.getNames=function(idioma){
                $timeout(function() {
                    getFromURL.async('messages/namesLabels', 'get', idioma).then(function(response){
                        $rootScope.namesLabels=response.data;
                    });
                    
                },0)
            };
    

    This $rootScope.labels = response.data; shows all labels in spanish

    (My spanish file.properties is somenthing like this:

    filter_name = Filtrar )
    

    but when I try this (for example):

    "language":{
    "sSearch":$rootScope.namesLabels.filter_name,
    .
    .
    .
    }
    

    it does not recognized the variable :( so there is the issue . For this reasons is always showing by default "Search" because it's like it doesn't recognize that rootScope :/

    Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • allanallan Posts: 63,210Questions: 1Answers: 10,415 Site admin

    I'm not sure I can help you with that I'm afraid as I'm not sure not sure what $rootScope is. I'd need a working example showing the issue, but even then it might be beyond the support we can provide since it doesn't appear to be specific to DataTables but rather to whatever framework you are using.

    Allan

This discussion has been closed.