Свойство jQWidgets jqxDataTable enableBrowserSelection

Опубликовано: 3 Января, 2023

jQWidgets — это JavaScript-фреймворк для создания веб-приложений для ПК и мобильных устройств. Это привлекательный, оптимизированный, независимый от платформы и широко поддерживаемый фреймворк. jqxDataTable используется для чтения и отображения данных из таблицы HTML. Это также используется для отображения данных из различных источников данных, таких как XML, JSON, Array, CSV или TSV.

Свойство enableBrowserSelection используется для включения или отключения выделения текста веб-браузером по умолчанию. Это логический тип, и его значение по умолчанию равно false.

Синтаксис:

  • Установите свойство enableBrowserSelection :
$("Selector").jqxDataTable({ enableBrowserSelection: true });
  • Верните свойство enableBrowserSelection :
var enableBrowserSelection = $("Selector").jqxDataTable("enableBrowserSelection");

Связанные файлы: Загрузите jQWidgets по данной ссылке. В файле HTML найдите файлы сценариев в загруженной папке.

<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<script type=”text/javascript” src=”scripts/jquery.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>

Пример 1: В приведенном ниже примере показано свойство jqxDataTable enableBrowserSelection в 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.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 enableBrowserSelection
            Property
        </h3>
        <div id="#Data_Table"></div>
        <table id="Data_Table" border="1">
            <thead>
                <tr>
                    <th>Employee_Name</th>
                    <th>Company</th>
                    <th>Designation</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Rohit</td>
                    <td>GeeksforGeeks</td>
                    <td>HR</td>
                </tr>
                <tr>
                    <td>Rahul</td>
                    <td>Capgemini</td>
                    <td>Software Engineer</td>
                </tr>
                <tr>
                    <td>Vivek</td>
                    <td>CESC</td>
                    <td>Electrical Engineer</td>
                </tr>
                <tr>
                    <td>Amit</td>
                    <td>Apple</td>
                    <td>Manager</td>
                </tr>
            </tbody>
        </table>
  
        <input type="button" 
               style="margin: 29px;" 
               id="jqxbtn" 
               value="Click here" />
        <div id="log"></div>
    </center>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#Data_Table").jqxDataTable({
                enableBrowserSelection: true,
                columns: [{
                    text: "Employee_Name",
                    dataField: "Employee_Name",
                    width: 190
                }, {
                    text: "Company",
                    dataField: "Company",
                    width: 160
                }, {
                    text: "Designation",
                    dataField: "Designation",
                    width: 190
                }]
            });
            $("#jqxbtn").jqxButton({
                width: 280
            });
            $("#jqxbtn").on("click", function () {
                var ebs = $("#Data_Table").jqxDataTable(
                    "enableBrowserSelection"
                );
                $("#log").text(ebs);
            });
        });
    </script>
</body>
  
</html>

Выход:

Пример 2. Ниже приведен еще один пример свойства jqxDataTable enableBrowserSelection , для которого задано значение «null».

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.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 enableBrowserSelection
            Property
        </h3>
        <div id="#Data_Table"></div>
        <table id="Data_Table" border="1">
            <thead>
                <tr>
                    <th>Employee_Name</th>
                    <th>Company</th>
                    <th>Designation</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Rohit</td>
                    <td>GeeksforGeeks</td>
                    <td>HR</td>
                </tr>
                <tr>
                    <td>Rahul</td>
                    <td>Capgemini</td>
                    <td>Software Engineer</td>
                </tr>
                <tr>
                    <td>Vivek</td>
                    <td>CESC</td>
                    <td>Electrical Engineer</td>
                </tr>
                <tr>
                    <td>Amit</td>
                    <td>Apple</td>
                    <td>Manager</td>
                </tr>
            </tbody>
        </table>
  
        <input type="button" 
               style="margin: 29px;" 
               id="jqxbtn" 
               value="Click here" />
        <div id="log"></div>
    </center>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#Data_Table").jqxDataTable({
                enableBrowserSelection: null,
                columns: [{
                    text: "Employee_Name",
                    dataField: "Employee_Name",
                    width: 190
                }, {
                    text: "Company",
                    dataField: "Company",
                    width: 160
                }, {
                    text: "Designation",
                    dataField: "Designation",
                    width: 190
                }]
            });
            $("#jqxbtn").jqxButton({
                width: 280
            });
            $("#jqxbtn").on("click", function () {
                var ebs = $("#Data_Table").jqxDataTable(
                    "enableBrowserSelection"
                );
                if (ebs === null) {
                    $("#log").text(ebs);
                }
                else {
                    $("#log").text("Not null!");
                }
            });
        });
    </script>
</body>
  
</html>

Выход:

Ссылка: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxdatatable/jquery-datatable-api.htm