Open In App

jQWidgets jqxDataTable localization Property

Last Updated : 15 Sep, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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=



Previous Article
Next Article

Similar Reads

jQWidgets jqxPasswordInput localization Property
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 jqxPasswordInput is a jQuery widget that enables the input field passwords with nice visual feedback about the password's strength. The localization property is
2 min read
jQWidgets jqxFileUpload localization Property
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. jqxFileUpload is a widget which can be used to select files and upload them to a server. The localization property is used to set various text values used in the wid
1 min read
jQWidgets jqxPivotGrid localization Property
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 jqxPivotGrid is a powerful and lightweight data visualization widget that is entirely written in JavaScript language. This widget is offering many advanced featu
2 min read
jQWidgets jqxScheduler localization Property
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 jqxScheduler widget is used to show a set of appointments in a day, week, month, timeline day, timeline week as well as timeline month views. The localization pr
3 min read
jQWidgets jqxTreeGrid localization Property
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 jqxTreeGrid is used for representing data in a tree-like structure. This widget is useful for displaying multi-column of hierarchical data, data paging, sorting
4 min read
jQWidgets jqxDataTable aggregatesHeight Property
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,
2 min read
jQWidgets jqxDataTable pagerPosition Property
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,
2 min read
jQWidgets jqxDataTable showHeader Property
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,
2 min read
jQWidgets jqxDataTable theme Property
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,
2 min read
jQWidgets jqxDataTable showToolbar Property
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,
2 min read