【问题标题】:How to get editable table如何获得可编辑的表格
【发布时间】:2016-10-31 14:25:48
【问题描述】:

最近我尝试使用可编辑表格,但是当我编辑一列时,整个表格结构都会受到影响,我将其显示为屏幕截图。

最初,

当我尝试编辑时,

我的html,

  <div class="widget-body">
        <table class="table table-hover">
           <thead>
              <tr>
                 <th class="hidden-xs-down">#</th>
                <th> <a (click)='getstudents(1)'>Account Name</a></th>
                <th class="hidden-xs-down"> <a (click)='getstudents(1)'>Phone</a></th>
                <th class="hidden-xs-down"> <a (click)='getstudents(1)'>Account Name ALias</a></th>
                 <th></th>
              </tr>
           </thead>
           <tbody>
              <tr *ngFor = 'let student of students'>
                 <td class="hidden-xs-down">{{id}}</td>
                 <td contenteditable="true">
                    <a>{{student.accountname}}</a>
                 </td>
                 <td contenteditable="true"  class ='phone'>
                    {{student.phone}}   
                 </td><i class = 'glyphicon glyphicon-pencil'></i>
                 <td contenteditable="true">
                    {{student.accountownername}}
                 </td>
                 <td>
                    <div class="btn-group" dropdown>
                       <button id="dropdown-btn-one" class="btn btn-xs" dropdownToggle>
                       <i class="fa fa-caret-down"></i>
                       </button>
                       <ul class="dropdown-menu dropdown-menu-right" dropdownMenu role="menu" aria-labelledby="dropdown-btn-one">
                          <li role="menuitem"><a class="dropdown-item pull-left"  (click) = 'getstudentbyid(student._id)'  data-toggle="modal" data-target="#editmodel">Edit</a></li>
                          <li role="menuitem"><a class="dropdown-item" (click) = 'deletestudentbyid(student._id)'>Delete</a></li>
                       </ul>
                    </div>
                 </td>
              </tr>

           </tbody>
        </table>

有人可以提供帮助吗。谢谢。

【问题讨论】:

    标签: jquery html css twitter-bootstrap


    【解决方案1】:

    一种方法是给标题宽度和可编辑的表格单元格word-break: break-all:

    编辑:为TD 添加宽度。没有它,在 Chrome 和 FF 中得到不同的结果。

    th {
        width:150px;
    }
    
    td {
      width: 150px;
      word-break: break-all;
    }
    

    http://jsbin.com/pejopadaju/edit?html,css,output

    【讨论】:

    • 对不起 Scandrett,仍然没有变化
    • E=谢谢 Scandrett,除了输入长值时输入框在移动之外,我几乎正在寻找它。
    • 你用的是什么浏览器?在 FF 中它不会为我移动
    • 我正在使用 chrome。
    猜你喜欢
    • 1970-01-01
    • 2013-06-15
    • 2013-03-06
    • 1970-01-01
    • 2011-08-26
    • 1970-01-01
    • 2013-03-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多