I render a page with two columns where one has input fields and the other one checkboxes. Lets say I modify an entry in one of the input fields and I uncheck a checkbox in another row.
我渲染一个包含两列的页面,其中一列有输入字段,另一列有复选框。假设我在其中一个输入字段中修改了一个条目,并取消选中另一行中的复选框。
Right now when I click the Save button and call the below code I receive all onscreen rows without it's properties modified with the new values (ie. I'm getting the original values and states from when the table originally loaded).
现在,当我单击“保存”按钮并调用下面的代码时,我会收到所有屏幕行,而不会使用新值修改其属性(即,我从原始加载的表中获取原始值和状态)。
save: function() {
var self = this;
var data = JSON.stringify(this.dataTable.rowData());
var url = this.urls.saveScreen;
var ajaxOptions = { url: url, data: data, contentType: "application/json", type: "POST"};
}
Is there different call available then "this.dataTable.rowData()" that I could use to receive:
是否有可用的“this.dataTable.rowData()”,我可以用来接收:
a.) only modified rows
a。)仅修改过的行
b.) rows with included changes to the input fields made by the user after the table was loaded.
b。)包含对表的加载后用户所做输入字段的更改的行。
1 个解决方案
#1
0
You can use hidden fields for that.. Add a hidden Field with the element changed in the table..
你可以使用隐藏的字段..添加一个隐藏的字段与表中更改的元素..
$('table > *').change(function(){
$(this).parent().append('<input type="hidden">changed</input>');
});
Now while checking you can search for rows having hidden input fields having value "changed"
现在,在检查时,您可以搜索具有值“已更改”的隐藏输入字段的行
Assuming it to be a table:
假设它是一个表:
$('input:hidden :contains("changed"').each(function(){
var row=$(this).closest('tr');
var firstElement=row.find('td:eq("0")').text();
var secondElement=row.find('td:eq("1")').text();
// and so on
});
This code is untested, But It should give you a workaround on how things should work..
此代码未经测试,但它应该为您提供有关事情应该如何工作的解决方法。
#1
0
You can use hidden fields for that.. Add a hidden Field with the element changed in the table..
你可以使用隐藏的字段..添加一个隐藏的字段与表中更改的元素..
$('table > *').change(function(){
$(this).parent().append('<input type="hidden">changed</input>');
});
Now while checking you can search for rows having hidden input fields having value "changed"
现在,在检查时,您可以搜索具有值“已更改”的隐藏输入字段的行
Assuming it to be a table:
假设它是一个表:
$('input:hidden :contains("changed"').each(function(){
var row=$(this).closest('tr');
var firstElement=row.find('td:eq("0")').text();
var secondElement=row.find('td:eq("1")').text();
// and so on
});
This code is untested, But It should give you a workaround on how things should work..
此代码未经测试,但它应该为您提供有关事情应该如何工作的解决方法。