I'm using the jQuery DataTables Editable to be able to edit data in a table. (Using jQuery 1.7.2) The data is fetched from an Asp.net web service. (See the code below)
When a value is empty (for example if one item in the list doesn't have a category) I don't want the category of that specific item to be editable. So the category for that item should be read-only. I didn't find a way to do this, is this possible?
<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>