Author Topic: Localization not working  (Read 2784 times)

inafking

  • Newbie
  • *
  • Posts: 10
    • View Profile
Localization not working
« on: December 30, 2015, 08:06:33 pm »
Hi, I was testing localization with paramquery grid and I tried the example posted here.

I've modified that code to show an example with no rows:
Code: [Select]

    $(function () {
        var colModel = [
{ title: "Title", dataType: "string", width: "150", dataIndx: 1 },
{ title: "Rights", dataType: "string", width: 150, dataIndx: 2 },
        { title: "Price", dataType: "float", width: 70, dataIndx: 3, align:"right", render:function(ui){
            var rowData=ui.rowData, cV=rowData[3];           
            return "$"+cV;
        } },
{ title: "Content", width: 320, dataIndx: 4 },
        { title: "Artist", dataType: "string", width: 120, dataIndx: 0 }
];

        var dataModel = {
            cache: true,
            location: "remote",           
            sortDir: "down",
            sorting: "local",                   
            dataType: "xml",
            getUrl: function () {
                return { url: "/Content/apple-albums.xml" };
            },
            getData: function (dataDoc) {
                //debugger;
                $(dataDoc).find("price").each(function(i,pNode){
                    var txt=$(pNode).text();
                    txt=txt.replace("$","");
                    $(pNode).text(txt);                   
                });
                var obj = { itemParent: "entry", itemNames: ["artist", "title", "rights", "price", "content" ] };
                return { data: [] }; //$.paramquery.xmlToArray(dataDoc, obj)
            }
        };
        var obj={
            width: 700,             
            dataModel: dataModel,
            colModel: colModel,           
            title: "<b>Albums Feed Reader</b>",
            flexHeight: true,
            flexWidth: true,           
            pageModel: {type:'local', rPP: 1, rPPOptions: [1, 2, 5, 10, 20, 100] },
            draggable: true
        };
       
        var $grid=$("div#grid-localize").pqGrid(obj);             

        $("#select-locale").change(function(evt){
            var locale=$(this).val();           
alert($.paramquery.pqGrid.regional[locale].strNoRows);
            $grid.pqGrid("option", $.paramquery.pqGrid.regional[locale]);           
            $grid.find(".pq-pager").pqPager("option", $.paramquery.pqPager.regional[locale]);           
        });
    });   

As it can be seen, I've modified the data in the dataModel to read an empty array ([]) and pressed "Edit and run". When I change the locale, it doesn't change the "no rows" string, despite having that set with the line:
Code: [Select]
$grid.pqGrid("option", $.paramquery.pqGrid.regional[locale]);   I put an alert to see if the locale was getting read and the variable was correctly set. Despite all that, the string doesn't change and it remains with the default value ("No rows to display").

Am I missing something?
I hope you can help me sort this out!

Thanks in advance!
Greets!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6296
    • View Profile
Re: Localization not working
« Reply #1 on: December 30, 2015, 09:14:11 pm »
Please recheck the demo with the applied fix:

Code: [Select]
  $grid.pqGrid("refresh");

inafking

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Localization not working
« Reply #2 on: December 31, 2015, 07:00:47 pm »
Thanks, it worked!

Greets!