Bootstrap значение строки двойного щелчка в таблице - PullRequest
0 голосов
/ 07 января 2020

Я пытаюсь получить значение строки после двойного щелчка в таблице bootstrap. Я не могу сделать это и возвращает меня неопределенным.

Мой код

$('#table').on('dbl-click-row.bs.table', function(field, value, row, $el) {
  if (value != "type") {
    alert($el.id + "-" + $el.name + "-" + $el.type);
  }
});

Ответы [ 2 ]

0 голосов
/ 07 января 2020

Пожалуйста, проверьте эту ссылку, вам нужно установить один общий class, чтобы получить значение строки

Нажмите меня

$(document).ready(function() {
 $(".jsTableRow").dblclick(function(){
  console.log($(this).html());
 alert($(this).html());
 });
});
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">            
  <table class="table table-striped">
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody style="cursor:pointer;" title="double click to get data">
      <tr class="jsTableRow">
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
      <tr class="jsTableRow">
        <td>Mary</td>
        <td>Moe</td>
        <td>mary@example.com</td>
      </tr>
      <tr class="jsTableRow">
        <td>July</td>
        <td>Dooley</td>
        <td>july@example.com</td>
      </tr>
    </tbody>
  </table>
</div>

</body>
</html>
0 голосов
/ 07 января 2020

это мой стол `

Seznam prvků

                        <table  class="table-sm"
                        id="table"
                        data-search="true" 
                        data-filter-control="true"
                        data-visible-search="true"
                        data-pagination="true"
                        data-pagination-h-align="left"
                        data-pagination-detail-h-align="right"

                        data-show-refresh="true"
                        data-show-columns="true">


                        <thead class="thead-light">
                              <tr>
                                <th data-checkbox="true"></th>
                                <th data-field="id"  data-filter-control="input" data-switchable="false">ID</th> 
                                <th data-field="key_fieldx"  data-sortable="true" data-filter-control="input">Keyfieldx</th>
                                <th data-field="delka"  data-sortable="true" data-filter-control="input">length</th>
                              </tr>
                            </thead>
                          </table>`
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...