【问题标题】:How to make some columns editable but some not in bootstrap table?如何使某些列可编辑但有些列不能在引导表中?
【发布时间】:2021-10-28 10:12:20
【问题描述】:

我有一个网络应用程序,前端有一个引导表,其数据从 Django REST 框架呈现。 由于数据是使用data-field渲染的,所以只有表头,没有表列。

我想让一些列可编辑,但有些不能,但没有这样做。 contenteditable='true'/'false' 标志在列级别上不起作用。 我怎样才能使某些列可编辑,而有些则不能?

            <table  contenteditable='true' class="table table-bordered table-sm" width="100%" cellspacing="0" style="font-size: 1.0rem;"
               id="bk-table"
               data-toggle="table"
               data-toolbar="#toolbar"
               data-cookie="true"
               data-cookie-id-table="materialId"
               data-show-columns="true"
               data-show-refresh="true"
               data-show-fullscreen="true"
               data-height="650"
               data-click-to-select="true"
               data-id-field="id"
               data-show-footer="true"
               data-url="/api/materials/"
               data-query-params="queryParams"
               data-remember-order="true"
               data-pagination="true"
               data-side-pagination="client"
               data-total-field="count"
               data-data-field="results">
            <thead class="thead-dark" >
            <tr contenteditable='true'>
                <th data-field="state" data-checkbox="true"></th>                   
                <th data-field="type">Course Type</th>                 

            </tr>
            </thead>

        </table>

【问题讨论】:

    标签: html django-rest-framework bootstrap-table


    【解决方案1】:

    使用引导表插件"x-editable" 使列可编辑或不可编辑使用 data-editable="true"data-editable="false"分别在&lt;tr&gt;

    例如

    <table id="my_table_id"
    <thead>
      <tr>
        <th class="col-md-1">#</th>
        <th class="col-md-4" data-editable="true">Name</th>
        <th class="col-md-7" data-editable="false">Description</th>
      </tr>
    </thead>
    </table>
    

    【讨论】:

    • 试过了,失败了。当我使用你的方法时,所有的列都变得不可编辑
    猜你喜欢
    • 2011-05-09
    • 2015-09-02
    • 2023-02-19
    • 2011-02-21
    • 2015-09-16
    • 1970-01-01
    • 2012-10-18
    • 1970-01-01
    • 2021-04-16
    相关资源
    最近更新 更多