Disable/Enable inline editing via API ?
Disable/Enable inline editing via API ?
JPC!
Posts: 13Questions: 2Answers: 0
I unsuccessfully searched the reference for a method to deactivate or activate inline editing for a table using editor. What I want to do is to set a "readonly" state for a while and to switch the table to writable later.
Thanks for any hint ;-)
Jens
Replies
Inline editing is triggered by your code calling the
inline()
method. So the way to disable it is to simply not call that method.There are a number of ways of doing that, but the right way will depend upon how you are calling it at the moment. Presumably in an event listener, so you could remove the event listener while in readonly mode, or put a check in the handler to see if you are in readonly mode before calling
inline()
.Allan
Hi Allan,
thanks for your reply ;-)
At the moment I don't use API explicitly. I call inline functionality by using the following in the table definition to get "Excel like" editing:
This of course is quite static. What I am looking for is to switch on and off inline editing dynamically. Maybe the event listener approach could be interesting for me to check out. Is there any helpful example?
Jens
Yep, you can use the KeyTable API for that,
keys.enable
andkeys.disable
. In this example, when you click the two buttons above the table, you either enable or disable inline editing.Colin
Hi Colin,
that made the trick ;-)
I had tried this before, without success. Your example made clear, I had had to check why it didn't work with my code. The reason was my use of a partial view resulting in using the keys.disable() before table initialization. I could resolve that by using the "init.dt" event.
Now everything is working perfectly, thanks a lot for your and Allan's help. I definitely appreciate receiving your answers within a very short time. Very helpful!
Jens
Awesome - great to hear you got it working!
Allan