How to dynamically disable a field (inline/edit form) based on value
How to dynamically disable a field (inline/edit form) based on value
Hey there,
I have a requirement to disable editing a field depending on the value in it. (e.g; if the media type is an empty string, it is editable)
I attempted to use this disable function example from another post but it doesn't actually get called (perhaps it just alters behavior when disabling the field)
{
data: "media_type",
disable: function (conf) {
console.log("I was called"); // doesn't log when interacting with/loading field
if (!isMediaTypeEditable($(conf._input)[0])) return;
conf._enabled = false;
$(conf._input).addClass("disabled");
},
title: 'Media Type'
}
There is a pure javascript solution for checking the input and manually disabling/enabling easily but I like to use the datatables API where I can to keep stuff clean. Any ideas if this behavior is supported?
This question has an accepted answers - jump to answer
Answers
You can do something like this. It's using
preOpen
to check for the form (this would also check for inline editing as well), and then there's another check to specifically handle inline data on the click event,Colin
Hey Colin,
The link you posted leads to a 404 for me.
The link to Colin's example does work:
http://live.datatables.net/qesaviqa/1/edit
Sometimes there are browser issue. Try clearing your browser's cache or a different browser.
Kevin
Colin's post helped me fix this, wound up using the opened event and disabling the input there. Thanks!