Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append in jQuery BootGrid reload grid data

I have problem with append row in bootgrid (http://www.jquery-bootgrid.com/)

I have grid with formatter use for insert multi row data

$("#grid-data").bootgrid({
        navigation : 0,
        selection: true,
        multiSelect: true,
        formatters : {

            "id" : function(col ,row) {
                return "<input type='hidden' class='form-control input-md' name='controls[][id]' value='"+row.id+"'/>";
            },

            "controlCode" : function (column ,row) {
                return "<input type='text' class='form-control input-md' name='controls[][controlCode]'/>";
            },
            "controlName" : function (column ,row) {
                return "<input type='text' class='form-control input-md' name='controls[][controlName]'/>";
            },
            "language" : function (column ,row) {
                return languageHtml;
            },
            "description" : function (column ,row) {
                return "<input type='text' class='form-control input-md' name='controls[][description]'/>";
            }
        }
    })

and have button with function to add new blank row

function addRow(){
    $("#grid-data").bootgrid("append", [{
        id  : 0,
        controlCode : "",
        controlName: "",
        language: "",
        description: ""
    }]);
};

When I input datas then create new blank row ,grid append new blank row but not keep my inputed data before

Any advice for me to keep inputted data? Thanks and sorry for my english

like image 569
user1993105 Avatar asked Jan 27 '26 17:01

user1993105


1 Answers

Since you are always passing the same value (zero) as id, bootgrid thinks this row already exists and just ignore it.

Try using different id values.

like image 194
Alisson Reinaldo Silva Avatar answered Jan 31 '26 18:01

Alisson Reinaldo Silva



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!