restrict editor.inline to a single column - without being able to edit the rest of the row.
restrict editor.inline to a single column - without being able to edit the rest of the row.
At the moment I'm having an issue with the following script, in that it will only initiate the inline editor when I click: td:last-child, but once it's selected the rest of the row becomes editable:
$('#line_items').on( 'click', 'tbody td:last-child', function (e) {
if (/*This condition returns true correctly*/){
editor.inline( this, {scope: 'cell', onBlur: 'submit'} );
}
} );
I'd like to only allow it to edit the cell in the last last column, and none of the others before it in the row.
Thanks in advance!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
That sounds odd! Your selector makes it look like only the last column in the table should do anything when clicked on. The other cells shouldn't be click to edit unless there is something else going on.
Are you able to give me a link to the page or show the unabridged code?
Thanks,
Allan
Hi @MSLtd ,
This example here may help. It shows how to restrict which columns can be inline edited.
I hope that helps, shout if not, and I'll try again!
Cheers,
Colin
@allan @colin I lied! it was mostly a logic error on my part - turns out the functions I called from
drawCallback()
leaned into the conditional statement which I had speculated returned true correctly (js if(poStatus == 'Ordered'){...}
) -poStatus
just so happens to be controlled by theselector
input in the final columnFor some reason whenever the cell is clicked, the selector automatically sets the selected option the 'lowest' option alphabetically and then submits the change to the database (In my case it was setting the selector to 'Cancelled' which in turn set
poStatus
to 'Cancelled' as well... so naturallypoStatus == 'Ordered'
was in fact returningfalse
and the event handler above it:was returning
true
- thus enabling the editing of the whole rowIs there anyway I can prevent the selector choosing 'Cancelled' as the default, whenever the field is selected?
So as it turned out, I was accidentally assigning the wrong variable to the Value of the selector!