I am using jquery-bootgrid Located here. http://www.jquery-bootgrid.com/GettingStarted
I created a bootgrid with fields one of them I want to edit so what I did was to specify it in the formatter.
formatters:
{
"fieldval": function(column, row)
{
return formatterForFieldval(column, row);
}
}
})
The function.
function formatterForFieldval(column, row)
{
return '<input type="text" class="form-control" id="usr" '
+ 'value="'+row.fieldval+'"'
+ '>' ;
}
This works and it creates a textbox that I can edit in runtime.
Now the next step is to save the modified data.
I use the following script to get the selected rows that the user modified.
function getSelectedRowsAsJson(tableId)
{
var selectedRowsArray =[];
var selectedRowsJsonArray = "";
var rows = $(tableId).bootgrid("getSelectedRows");
var arrayLength = rows.length;
for (var i = 0; i < arrayLength; i++)
{
var rowsc = $(tableId).bootgrid("getCurrentRows");
var arrayLengthCurrent = rowsc.length;
for (var ii = 0; ii < arrayLengthCurrent; ii++)
{
if(rows[i]===rowsc[ii].id)
{
selectedRowsArray.push(rowsc[ii])
}
}
}
selectedRowsJsonArray = JSON.stringify(selectedRowsArray);
console.log(selectedRowsJsonArray);
return selectedRowsJsonArray;
}
My issue is that var rowsc = $(tableId).bootgrid("getCurrentRows");
is not updated to the modified data that I typed into the textbox.. It still shows the old data (loaded data) before I modified the text box.
So when sending the array of rows to the database it updates to the same values.
How do I update var rowsc = $(tableId).bootgrid("getCurrentRows");
after I have modified the textbox ? Or am I doing it wrong?