如何在数据表中编辑
How to Edit in Datatable
我在 html 页面中将 Datatables(https://datatables.net) 与 jQuery 一起使用。我对 Datatable api 以及 JQuery.The 代码的相关部分非常陌生,如下所示:
//Some Code...
<table class="table table-striped table-bordered table-hover"
id="dataTables-companyGroupFilter">
<thead>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</thead>
<tbody id="companyGroupFilterDetails">
</tbody>
</table>
JavaScript:
//Some Code...
var dataTableGroupCompany = $('#dataTables-companyGroupFilter').DataTable({
'sDom' : 'tp',
"bDeferRender": true,
"aoColumns": [
{"sClass": "col1" },
{"sClass": "col2" },
null,
null,
],
"iDisplayLength" : 20}).rowGrouping({
bExpandableGrouping:true, iGroupingColumnIndex:3,
fnGroupLabelFormat:function(label){
if(mapCompany[label]!=null) return label+" ("+mapCompany[label]+")"; else return label; }});
//Some Code...
dataTableGroupCompany.fnAddData(
["<img src='"+pic+"' style='height: 80px;' class='person-link' person-uri='"+value["uri"]+"'>",
" <br><i class='" + employmentCssClass + "' style='padding-top: 5px;'></i><br><i class='" + placeCssClass + "' style='padding-top: 5px;'></i> <br><i class='" + organisationCssClass + "' style='padding-top: 3px;'></i>",
"<b><a class='person-link' person-uri='"+value["uri"]+"'>"+name+"</a></b> <br>"+desig+"<br>"+place+"<br>"+organisation, organisation,mapCompany[organisation]],false);
最后一列 mapCompany[organization]
只是整数。
我想要做的是迭代每一行并使用第三列的数据作为 Hashmap 中的键替换第四列,即 mapCompany[organisation],其中 organization 可以是第三列中的键。
绘制 table 时创建的每一行的回调:
"fnCreatedRow" : function(nRow, aData, iDataIndex) {
$('td:last-child', nRow).text(100);
}
查看我刚刚创建的 fiddle:http://jsfiddle.net/yrn2nfj3/
我在 html 页面中将 Datatables(https://datatables.net) 与 jQuery 一起使用。我对 Datatable api 以及 JQuery.The 代码的相关部分非常陌生,如下所示:
//Some Code...
<table class="table table-striped table-bordered table-hover"
id="dataTables-companyGroupFilter">
<thead>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</thead>
<tbody id="companyGroupFilterDetails">
</tbody>
</table>
JavaScript:
//Some Code...
var dataTableGroupCompany = $('#dataTables-companyGroupFilter').DataTable({
'sDom' : 'tp',
"bDeferRender": true,
"aoColumns": [
{"sClass": "col1" },
{"sClass": "col2" },
null,
null,
],
"iDisplayLength" : 20}).rowGrouping({
bExpandableGrouping:true, iGroupingColumnIndex:3,
fnGroupLabelFormat:function(label){
if(mapCompany[label]!=null) return label+" ("+mapCompany[label]+")"; else return label; }});
//Some Code...
dataTableGroupCompany.fnAddData(
["<img src='"+pic+"' style='height: 80px;' class='person-link' person-uri='"+value["uri"]+"'>",
" <br><i class='" + employmentCssClass + "' style='padding-top: 5px;'></i><br><i class='" + placeCssClass + "' style='padding-top: 5px;'></i> <br><i class='" + organisationCssClass + "' style='padding-top: 3px;'></i>",
"<b><a class='person-link' person-uri='"+value["uri"]+"'>"+name+"</a></b> <br>"+desig+"<br>"+place+"<br>"+organisation, organisation,mapCompany[organisation]],false);
最后一列 mapCompany[organization]
只是整数。
我想要做的是迭代每一行并使用第三列的数据作为 Hashmap 中的键替换第四列,即 mapCompany[organisation],其中 organization 可以是第三列中的键。
绘制 table 时创建的每一行的回调:
"fnCreatedRow" : function(nRow, aData, iDataIndex) {
$('td:last-child', nRow).text(100);
}
查看我刚刚创建的 fiddle:http://jsfiddle.net/yrn2nfj3/