Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit row in bootstrap-table

I have used boostrap-table in my JSP page

<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>

and I have inserted the editable method in my 3rd column which in front-end it works.

I try to catch the new value I insert in my table(e.g I edit a row and I insert the '12'): I have tried this:

$(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);
    });    
});

but in console i get:

1 [object Object]
2 lot
3 [object Object]
4 002400000 // this is the old one
like image 729
yaylitzis Avatar asked Dec 03 '25 02:12

yaylitzis


1 Answers

$(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);
    });    
});

Here you can get new value using row[field] or row.lot

like image 162
Asiri Jayaweera Avatar answered Dec 04 '25 16:12

Asiri Jayaweera



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!