我正在使用jQuery DataTables Editable来编辑表格中的数据(使用jQuery 1.7.2)。这些数据是从一个Asp.net web服务获取的(请参见下面的代码)。
当某个值为空时(例如,如果列表中的某个项目没有类别),我不希望该特定项目的类别可编辑。因此,该项目的类别应为只读。我找不到实现此功能的方法,这是否可能?
当某个值为空时(例如,如果列表中的某个项目没有类别),我不希望该特定项目的类别可编辑。因此,该项目的类别应为只读。我找不到实现此功能的方法,这是否可能?
<table id="admin_list" cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th>Title</th>
<th>Category</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function () {
function renderTable(result) {
var dtData = [];
$.each(result, function () {
dtData.push([
this.title,
this.category
]);
});
$('#admin_list').dataTable({
'aaData': dtData
}).makeEditable({
sReadOnlyCellClass: "read_only",
sUpdateURL:"Service.svc/update",
"aoColumns":
[
{}, //title
{} //category
]
});
}
$.ajax({
type: "GET",
url: "Service.svc/list",
dataType: "json", cache: false, data: {}, contentType: "application/json; charset=utf-8",
success: function (data) {
renderTable(data.d);
},
error: function (data) {}
});
});
</script>