页面加载时检查引导表复选框

2024-01-12

我在用引导表 http://bootstrap-table.wenzhixin.net.cn/documentation/我正在尝试设置复选框,问题是复选框在没有特殊原因的情况下被启动为选中状态

    <html>

    <head>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <meta name="robots" content="noindex, nofollow">
      <meta name="googlebot" content="noindex, nofollow">
      <script type="text/javascript" src="//code.jquery.com/jquery-2.1.0.js"></script>
      <script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
      <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
      <link rel="stylesheet" type="text/css" href="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.css">
      <script type="text/javascript" src="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.js"></script>
      <title>Bootstrap Table</title>
    </head>
    <body>
      <div class="container">
        <div class="container">
  <div class="row">
    <div class="col-md-12">
      <div class="panel panel-primary">
        <div class="panel-heading">why checked?</div>

        <div class="panel-body">
          <table data-row-style="rowStyle" data-toggle="table" data-click-to-select="true">
            <thead>
              <th data-field="dd" data-checkbox="true">
              </th>
              <th data-sortable="true">
                x
              </th>
              <th data-sortable="true">
                y
              </th>
              <th data-sortable="true">
                z
              </th>
              <th data-sortable="true">
                t
              </th>
              <th data-sortable="true">
                r
              </th>
              <th data-sortable="true">
                m
              </th>
              <th></th>
            </thead>
            <tbody>
              <tr>
                <td>
                </td>
                <td> 1</td>
                <td>2</td>
                <td>3</td>
                <td> 4</td>
                <td> 5</td>
                <td><span class="label label-default">xxx</span></td>
                <td>
                  <div class="form-inline text-right">
                    <form class="form-group" action="{{url('invobj')}}/{{$obj->id}}/edit" method="post">
                      <button class="btn btn-primary btn-xs"><i class="glyphicon glyphicon-pencil"></i></button>
                    </form>
                    <form class="form-group" action="{{url('invobj')}}/{{$obj->id}}" method="post">
                      <input name="_method" type="hidden" value="DELETE">
                      <input type="hidden" name="_token" value="{{csrf_token()}}">
                      <button class="btn btn-warning btn-xs"><i class="glyphicon glyphicon-remove"></i></button>
                    </form>
                  </div>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>

      </div>
    </body>
    </html>

demo:http://jsfiddle.net/e3nk137y/12160/ http://jsfiddle.net/e3nk137y/12160/

第二个问题,如何向复选框添加名称和值,我尝试从data-formatter功能,但在开发工具中没有看到任何改变

该文档没有提及自定义复选框的任何属性/功能/事件

Update似乎如果您想对所选元素进行排序,第一列(复选框列)就会消失


当引导表在表格单元格中发现空白字符时,看到引导表崩溃实际上是很有趣的。一旦它们被修剪掉包括换行符在内的任何空白字符,问题似乎就会自行解决。

function check() {
  $("tbody input:checked").each(function() {
    console.log($(this).parents("tr:first").data("val"));
  });
}
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.0.js"></script>
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.css">
<script type="text/javascript" src="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.js"></script>
<div class="container">
  <div class="container">
    <div class="row">
      <div class="col-md-12">
        <div class="panel panel-primary">
          <div class="panel-heading">why checked?</div>
          <div class="panel-body">
            <button onclick="check()">Check Values</button>
            <table data-row-style="rowStyle" data-toggle="table" data-click-to-select="true">
              <thead>
                <th data-field="dd" data-checkbox="true">
                </th>
                <th data-sortable="true">
                  x
                </th>
                <th data-sortable="true">
                  y
                </th>
                <th data-sortable="true">
                  z
                </th>
                <th data-sortable="true">
                  t
                </th>
                <th data-sortable="true">
                  r
                </th>
                <th data-sortable="true">
                  m
                </th>
                <th></th>
              </thead>
              <tbody>
                <tr data-val="100">
                  <td></td>
                  <td>100</td>
                  <td>200</td>
                  <td>300</td>
                  <td>400</td>
                  <td>500</td>
                  <td><span class="label label-default">xxx</span></td>
                  <td>
                    <div class="form-inline text-right">
                      <form class="form-group" action="{{url('invobj')}}/{{$obj->id}}/edit" method="post">
                        <button class="btn btn-primary btn-xs"><i class="glyphicon glyphicon-pencil"></i></button>
                      </form>
                      <form class="form-group" action="{{url('invobj')}}/{{$obj->id}}" method="post">
                        <input name="_method" type="hidden" value="DELETE">
                        <input type="hidden" name="_token" value="{{csrf_token()}}">
                        <button class="btn btn-warning btn-xs"><i class="glyphicon glyphicon-remove"></i></button>
                      </form>
                    </div>
                  </td>
                </tr>
                <tr data-val="200">
                  <td></td>
                  <td>200</td>
                  <td>200</td>
                  <td>300</td>
                  <td>400</td>
                  <td>500</td>
                  <td><span class="label label-default">xxx</span></td>
                  <td>
                    <div class="form-inline text-right">
                      <form class="form-group" action="{{url('invobj')}}/{{$obj->id}}/edit" method="post">
                        <button class="btn btn-primary btn-xs"><i class="glyphicon glyphicon-pencil"></i></button>
                      </form>
                      <form class="form-group" action="{{url('invobj')}}/{{$obj->id}}" method="post">
                        <input name="_method" type="hidden" value="DELETE">
                        <input type="hidden" name="_token" value="{{csrf_token()}}">
                        <button class="btn btn-warning btn-xs"><i class="glyphicon glyphicon-remove"></i></button>
                      </form>
                    </div>
                  </td>
                </tr>
                <tr data-val="300">
                  <td></td>
                  <td>300</td>
                  <td>200</td>
                  <td>300</td>
                  <td>400</td>
                  <td>500</td>
                  <td><span class="label label-default">xxx</span></td>
                  <td>
                    <div class="form-inline text-right">
                      <form class="form-group" action="{{url('invobj')}}/{{$obj->id}}/edit" method="post">
                        <button class="btn btn-primary btn-xs"><i class="glyphicon glyphicon-pencil"></i></button>
                      </form>
                      <form class="form-group" action="{{url('invobj')}}/{{$obj->id}}" method="post">
                        <input name="_method" type="hidden" value="DELETE">
                        <input type="hidden" name="_token" value="{{csrf_token()}}">
                        <button class="btn btn-warning btn-xs"><i class="glyphicon glyphicon-remove"></i></button>
                      </form>
                    </div>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

我在每一行和函数中添加了 data-valcheck()将记录所选行的值。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

页面加载时检查引导表复选框 的相关文章

随机推荐

  • IE7 仅忽略来自生产服务器的页面上的 CSS 属性选择器

    在我的网站上 IE7 似乎忽略了某些 CSS 属性选择器 奇怪的是 只有当页面来自生产服务器时才会发生这种情况 如果我有完全相同的代码在我的个人服务器上 或者保存在我的硬盘上 它工作得很好 这是导致该问题的示例
  • R 中的“不加入”

    我正在寻找一种快速的方法来 不加入 即保留未合并的行 或内部联接的逆 我一直在做的方法是使用 data table 作为 X 和 Y 然后设置键 例如 require data table X lt data table category
  • 在 OSX 中捕获媒体键(播放/暂停)

    研究 问题 中年危机 有一些问题here https stackoverflow com questions 2477068 listening to mac keyboard play pause events and there htt
  • JGit:检索与 git 提交关联的标签

    我想使用 JGit API 检索与特定提交哈希相关的标签 如果有的话 请提供相同的代码片段 Git 对象模型 http book git scm com 1 the git object model html将标签描述为包含有关特定对象的信
  • @Order注解对XML序列化顺序没有影响

    我正在使用 Retrofit 2SimpleXmlConverter我在创建 Soap 请求对象时遇到一个问题 该对象基本上是一个具有 4 个元素子元素的元素 每个子元素都是不同的数据类型 这里是XML我想要产生的输出 必须遵守元素顺序
  • 如何在 Xcode 9 中使用带有 Playground 的自定义框架

    我正在尝试在 Playground 中使用自定义框架 如 Apple 文档中所述 http help apple com xcode mac 9 0 devc9b33111c http help apple com xcode mac 9
  • Eclipse 上安装的插件不可见

    当我在 Eclipse 中安装插件时 一切都很顺利 但重启后新插件就看不见了 我尝试过使用不同的插件 但它们都有同样的问题 我能看到它们的唯一地方是当我查看 已安装什么 时 可能是什么问题呢 这个问题及其解决方案在DZone 文章 http
  • 我正在用 C 搜索 cgi 库来构建一个安静的 Web 服务

    我想构建一个安静的 CoAP Web 服务 它可以执行 C 代码来处理事件 因此我正在搜索一个lib 它为我提供了C和cgi中的rest api 类似于 遗憾的是 restcgi 是用 c 编写的 而 CGI Simple 是用 perl
  • System.Data.SqlClient.SqlException:列名“Gender_id”无效

    我正在学习使用 ASP NET MVC 和实体框架进行 Web 应用程序开发 我有一个包含 3 个表的数据库 分别是学生 性别和课程 我遇到了这个问题 错误位于第 23 行 列名称 Genders Id 无效 列名 Programs Id
  • ruby 方法名称中的变量

    我有以下代码 for attribute in site device attributes device attribute end 我希望代码用 属性 的值替换方法名称 我努力了device attribute 以及各种排列 这完全不可
  • 找不到文本月份,跟踪数据 Carbon - laravel

    我确实尝试了不同的方法 但没有得到正确的时间格式 news gt created at Carbon parse news gt created at gt format M d Y news gt created at date d M
  • OpenCV DFT_INVERSE与Matlab的ifft不同

    我尝试使用 opencv 的 dft 函数过滤信号 我尝试的方法是在时域中获取信号 x 0 0201920000000000 0 0514940000000000 0 0222140000000000 0 0142460000000000
  • getenv() 的全局变量?

    哪个全局变量保存了 getenv 的所有环境变量 在哪个 glibc 文件中 这个 var 填充了 env vars 我相信它是 environ 但是当我在 bash 中设置环境变量时 它只输出 SSH AGENT PID 环境变量 为什么
  • 什么是 SQL“伪列”?

    我不小心编码了SELECT FOO 并收到错误 无效的伪列 FOO 我找不到他们的任何文档 这是我应该知道的事情吗 编辑 这是一个 MS SQL Server 特定问题 伪列是实际列的符号别名 具有特殊属性 例如 IDENTITY 是分配了
  • Cordova PushPlugin:应用程序未运行时 Android 不会播放推送声音

    我正在使用推送插件 https github com phonegap build PushPlugin对于cordova 以及在android中 当应用程序未运行或在后台时 我无法使推送通知播放声音 状态栏中的横幅显示正常 这是在 and
  • java.lang.IllegalArgumentException:API接口不得扩展其他接口Retrofit 2

    我在使用 Retrofit 2 beta 2 时遇到了下一个问题 java lang IllegalArgumentException API interfaces must not extend other interfaces 这是因为
  • 访问非指令控制器函数内的属性值

    HTML 内容
  • Hydra MPI 的最大进步是什么

    我正在研究 MPICH2 自动附带的新流程管理器 但到目前为止我无法弄清楚这个实现有什么重大进步 有人知道一个好的教程或有一些经验吗 argonne wiki 有点太简单了 http wiki mcs anl gov mpich2 inde
  • Lua检查文件是否打开

    我正在尝试编写一个 lua 文件脚本来检查某个文件是否打开 然后我希望它关闭该文件 如果该文件已打开 我知道如何检查文件是否存在 但我需要知道如何检查文件是否打开 即文件正在运行 Lua 与 C C 和几乎所有其他语言一样 只能关闭它打开的
  • 页面加载时检查引导表复选框

    我在用引导表 http bootstrap table wenzhixin net cn documentation 我正在尝试设置复选框 问题是复选框在没有特殊原因的情况下被启动为选中状态