繁体   English   中英

编辑bootstrap-table中的行

[英]Edit row in bootstrap-table

我在JSP页面中使用了boostrap-table

<table id="mytable" 
   data-row-style="rowStyle" class="table table-hover" id="table-pagination " 
   data-url="lots.json" 
   data-toggle="table"
   data-pagination="true"
   data-show-pagination-switch="true"
   data-sort-order="desc" 
   data-search="true"
   data-show-refresh="true" 
   data-show-columns="true"

   data-page-list="[10, 25, 50, 100, ALL]"                     
>

    <thead>
        <tr>
            <th data-field="machine" data-align="center" data-sortable="true">machine</th>
            <th data-field="mould" data-align="center" data-sortable="true">mould</th>
            <th data-field="lot" data-editable="true" data-align="center" data-sortable="true">LOT</th>         

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

我已经在我的第3列插入了可编辑的方法 ,它在前端工作。

我尝试捕获我在表格中插入的新值(例如,我编辑一行并插入'12'):我试过这个:

$(function() {
    $('#mytable').on('editable-save.bs.table', function(field, row, oldValue, $el){
        console.log("1 "+ field);
        console.log("2 "+ row);
        console.log("3 "+ oldValue);
        console.log("4 "+ $el);
    });    
});

但在控制台我得到:

1 [object Object]
2 lot
3 [object Object]
4 002400000 // this is the old one
$(function() {
    $('#mytable').on('editable-save.bs.table', function(e, field, row, oldValue){
        console.log("1 "+ field);
        console.log("2 "+ row[field]);
        console.log("3 "+ row.lot);
        console.log("4 "+ oldValue);
    });    
});

在这里,您可以使用row [field]或row.lot获取新值

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM