Skip to content
Related Articles
Open in App
Not now

Related Articles

jQWidgets jqxDataTable localization Property

Improve Article
Save Article
  • Last Updated : 15 Sep, 2022
Improve Article
Save Article

jQWidgets is a JavaScript framework for making web-based applications for PC and mobile devices. It is a very powerful, optimized, platform-independent, and widely supported framework. The jqxDataTable is used for reading and displaying the data from the HTML Table. This is also used to display data from various data sources like  XML, JSON, Array, CSV, or TSV.

The localization property is used to apply localization to the strings of the displayed jqxDataTable. It is of object type and its default value is default localization strings.

Syntax:

  • Set the localization property.
$('Selector').jqxDataTable({ 
   localization: default localization strings,
});
  • Return the localization property.
var localization = $('Selector').jqxDataTable('localization');

Linked Files: Download jQWidgets from the given link. In the HTML file, locate the script files in the downloaded folder.

<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<script type=”text/javascript” src=”scripts/jquery-1.11.1.min.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxdata.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxbuttons.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxscrollbar.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxlistbox.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxdropdownlist.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxdatatable.js”></script>

 Approach: 

  • Add all the links required to the JavaScript files. 
  • An HTML div element is created inside the body part of the stated HTML document with id=”jqxdt” in the below example.
  • The widget displayed data table is initialized with the help of the source as well as column properties. Moreover, the localization property is illustrated where the localization object with respect to the pagerRangeString is set to ‘total-‘. 

Example 1: The below example illustrates the jqxDataTable localization property in jQWidgets.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <link rel="stylesheet" href=
            "jqwidgets/styles/jqx.base.css" 
            type="text/css"/>
    <script type="text/javascript" 
            src="scripts/jquery-1.11.1.min.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxcore.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxdata.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxbuttons.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxscrollbar.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxlistbox.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxdropdownlist.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxdatatable.js">
    </script>
</head>
  
<body>
    <center>
        <h1 style="color: green">
            GeeksforGeeks
        </h1>
  
        <h3>jQWidgets jqxDataTable localization Property</h3>
  
        <div id="jqxdt"></div>
        <br>
        <input type="button" style="margin:29px;" 
               id="jqxbtn" value="Click here" />
        <div id="log"></div>
    </center>
  
    <script type="text/javascript">
        $(document).ready(function () {
            var d = new Array();
            var subjectNames =
                ["C++", "Scala", "Java","C", "R", "JavaScript"];
  
            var pageNumber =
                ["7", "8", "12", "11", "10", "19"];
  
            for (var j = 0; j < 27; j++) {
                var r = {};
                r["subjectnames"] = subjectNames[
                    Math.floor(Math.random() * subjectNames.length)];
  
                r["pagenumber"] = pageNumber[
                    Math.floor(Math.random() * pageNumber.length)];
                d[j] = r;
  
            }
            var src = {
                localdata: d,
                datatype: "array",
            };
            var gloc = function () {
                var locobj = {};
                locobj.pagerRangeString = " total- ";
                return locobj;
            }
            var data_Adapter = new $.jqx.dataAdapter(src);
            $("#jqxdt").jqxDataTable({
                source: data_Adapter,
                localization: gloc(),
                pageable: true,
                width: 320,
                height: 170,
                columns: [
                    {
                        text: "Subject Name",
                        datafield: "subjectnames",
                        width: "160px",
                    },
                    {
                        text: "Page No.",
                        datafield: "pagenumber",
                        width: "160px",
                    },
                ],
            });
            $("#jqxbtn").jqxButton({
                width: 280
            });
            $("#jqxbtn").on("click", function () {
                var ls = $('#jqxdt').jqxDataTable('localization');
                $("#log").text(ls.pagerRangeString)
            });
        });
    </script>
</body>
</html>


Output:

 

Example 2: The following is another example of the jqxDataTable localization property in jQWidgets. The localization property is set to “null”, so none of the strings are localized, and “null” is returned as output.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <link rel="stylesheet" href=
            "jqwidgets/styles/jqx.base.css" 
            type="text/css"/>
    <script type="text/javascript" 
            src="scripts/jquery-1.11.1.min.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxcore.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxdata.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxbuttons.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxscrollbar.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxlistbox.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxdropdownlist.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxdatatable.js">
    </script>
</head>
  
<body>
    <center>
        <h1 style="color:green">
            GeeksforGeeks
        </h1>
  
        <h3>jQWidgets jqxDataTable localization Property </h3>
  
        <div id="jqxdt"></div>
        <br>
        <input type="button" style="margin:29px;" 
               id="jqxbtn" value="Click here" />
        <div id="log"></div>
    </center>
  
    <script type="text/javascript">
        $(document).ready(function () {
            var d = new Array();
            var subjectNames =
                ["C++", "Scala", "Java","C", "R", "JavaScript"];
  
            var pageNumber =
                ["7", "8", "12", "11", "10", "19"];
  
            for (var j = 0; j < 27; j++) {
                var r = {};
                r["subjectnames"] = subjectNames[
                    Math.floor(Math.random() * subjectNames.length)];
  
                r["pagenumber"] = pageNumber[
                    Math.floor(Math.random() * pageNumber.length)];
                d[j] = r;
            }
            var src = {
                localdata: d,
                datatype: "array",
            };
            var data_Adapter = new $.jqx.dataAdapter(src);
            $("#jqxdt").jqxDataTable({
                source: data_Adapter,
                localization: null,
                pageable: true,
                width: 320,
                height: 170,
                columns: [
                    {
                        text: "Subject Name",
                        datafield: "subjectnames",
                        width: "160px",
                    },
                    {
                        text: "Page No.",
                        datafield: "pagenumber",
                        width: "160px",
                    },
                ],
            });
            $("#jqxbtn").jqxButton({
                width: 280
            });
            $("#jqxbtn").on("click", function () {
                var ls = $('#jqxdt').jqxDataTable('localization');
                if (ls === null) {
                    $('#log').text("Null!");
                }
                else {
                    $('#log').text("Not null!");
                }
            });
        });
    </script>
</body>
</html>


Output:

 

Reference: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxgrid/jquery-grid-api.htm?search=


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!