1、第一步獲取數據源
var rows = { //要插入的數據,這里要和table列名一致
SkuCode: data.rows[i].SkuCode,
BarCode: data.rows[i].BarCode,
ProductName: data.rows[i].ProductName,
prospec: data.rows[i].prospec,
ItemName: data.rows[i].ItemName,
ReceiptQuantity: 0,
LnQuantity: data.rows[i].LnQuantity,
NotQuantity: 0,
CostPrice: data.rows[i].CostPrice,
YKPrice: "",
SkuId: data.rows[i].SkuId,
ProId: data.rows[i].ProId
}
$('#gridList').bootstrapTable('insertRow', {
index: 0,
row: rows
});
2、表格改動屬性的標簽 加入一下兩個屬性
data-index="' + index + '" onkeyup="GetInputByQuatity(this)"
data-index="' + index + '" onkeyup="GetInputBySumprices(this)"
3、再寫入標簽兩個方法 需要不刷新的字段 保存下來一下兩個方法
function GetInputByQuatity(obj)
{
var row = {
pronum: $(obj).val(),
sumprice: 10.0
}
$('#gridList').bootstrapTable('updateRow', { index: $(obj).data('index'), row: row })
}
function GetInputBySumprices(obj) {
var row = {
pronum: 5,
sumprice: $(obj).val()
}
$('#gridList').bootstrapTable('updateRow', { index: $(obj).data('index'), row: row })
}
4、表格刷新
$("#gridList").bootstrapTable('refresh');