【问题标题】:bootstrap table ions on specific row特定行上的引导表离子
【发布时间】:2015-11-29 23:23:33
【问题描述】:

我可以从 JSON 输出成功显示引导表,但是我不知道如何在最后一列上填充一个按钮以显示在每一行中

<table class = "table table-hovergrey" data-search="true"  data-toggle="table" data-url="php/data.php" data-height="auto">
            <thead>
                <tr>
                    <th data-field="ID">ID</th>
                    <th data-field="Name">Name</th>
                    <th data-field="Age">Age</th>

                </tr>
            </thead>
        </table> 

PHP 代码

<?php
   // DB Credentials goes here
        $db_name  = 'dbName';
        $hostname = 'hostname';
        $username = 'username';
        $password = 'password'; 
// connect to the database

 $dbh = new PDO("mysql:host=$hostname;dbname=$db_name", $username, $password);

// a query get all the records from the users table
        $sql = 'select ID,Name,Age from PEOPLE ';

// use prepared statements, even if not strictly required is good    practice
        $stmt = $dbh->prepare( $sql );

        // execute the query
        $stmt->execute();

        // fetch the results into an array
        $result = $stmt->fetchAll( PDO::FETCH_ASSOC );

        // convert to json
        $json = json_encode( $result );

        // echo the json string
        echo $json;
?>

【问题讨论】:

  • 表上的数据是从 PHP 文件中填充的,我从 SQL 数据库中获取数据并将结果存储在 JSON 输出中

标签: php sql twitter-bootstrap-3 html-table


【解决方案1】:

我没有足够的代表发表评论 - 但我不确定你是如何填充表格的 - 也许你有一个自定义指令 data-url

这是一个通过$http 从 Angular 控制器获取 JSON 数据的标准示例(通常您会在服务中进行 http 调用,但为了演示......)。

HTML 是模板化的,并使用ng-repeat 创建表格行。这样您就可以完全控制标记,并且可以轻松创建&lt;button&gt;。这是 Codepen 上的一个工作示例:http://codepen.io/TheFoot/pen/bVdrxQ

【讨论】:

  • 哎呀!我本可以发誓这被标记为 angular :) 然后忽略我.. 也许这对想要角度解决方案的人有用!
猜你喜欢
  • 1970-01-01
  • 2019-02-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-27
  • 1970-01-01
相关资源
最近更新 更多