What selector gets cell that was clicked on?
What selector gets cell that was clicked on?
Editor v1.4. Inline editing.
In the preOpen
event, what jQuery selector should I use to return the cell the user clicked on? And then, how do I check if it has 'my-class' assigned to it? (The class name I'm after is the name assigned in the tables columns property className
.)
I use this in the open
event and it works just fine (because I guess the editor is created) but it is not working in preOpen
cell = $('div.DTE').parent();
cell.hasClass('my-class');
Thank you.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Use the
modifier()
method to get the "modifier" that was used to trigger the editing - e.g. the cell in this case.Allan
Thanks Allan.
I'm having a problem getting what I need. In Editor's
preOpen
event handler,editor.modifier()
seems to be returning the index of the row being edited. If that's the case, how does that help me know what cell is about to be edited (or even what column the cell is in)?This is what I need to be able to do. My interface is very rule based.
If a the value in cell in column 2 in the row (
inline()
editing) is equal to say '2', I want to prevent the editor from opening in say the cell in the same row in column 6. I have to be able to prevent the Editor open (thus want to returnfalse
inpreOpen
) whether the user has navigated to the cell using the keyboard, by clicking on it with a mouse or even if they touched it.My columns are in a static order, so knowing either the column number or the
className
of the column the editor is about to act upon would work for me.Is
editor.modifier()
in thepreOpen
event really the solution for this?Can you show me the code you are using please? I had assumed that you are using an event handler to trigger inline editing on a cell, but that won't be the case if you are getting a row index from
modifier()
.Allan
Actually, your reply gave me another idea, but here's the code:
var m
is an integer.Since I'm trapping the
keydown.editor
event following your tab navigation example, and theclick
event is being fired there, I can block the editor from opening in above code. I don't have to block inpreOpen
. But still, I would be interested in knowing if you expectm
to be an integer or not.That sounds like a bug to me - it should be the cell node. Let me look into it (travelling at the moment) and confirm if it is fixed in 1.5 (it should be - I've completely rewritten that part).
Allan
Hi Allan - did you have a chance to look at this? That is, are you able yet to confirm if this is a DataTable bug?
Thanks,
Karl
Sorry, yes, I forgot to reply. This is a bug and it is fixed in 1.5, which is as yet unreleased (it will be later this month :-) ). Using
modifier()
after callinginline()
passing a cell will causemodifier()
to return a cell.Allan
Thanks for the update.