Adding a field (checkbox) to the remove form
Adding a field (checkbox) to the remove form
dynasoft
Posts: 446Questions: 69Answers: 3
Hi
I'm trying to add a checkbox to the remove editor form but I can't see howt thats done. I tried this for ex., but the field isn't showing:
var editor2 = new $.fn.dataTable.Editor({...}).add( {
type: "checkbox",
label: "Locations:",
name: "locations",
options: [
{ label: "Edinburgh", value: 51 },
{ label: "London", value: 76 }
]
} );
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This discussion has been closed.
Answers
Hi @dynasoft ,
I don't believe that's possible. You can change the message, see here, but you can't created editable fields - there's no point, since the record is going to be deleted.
What's the use case for wanting to do this?
Cheers,
Colin
Hi
It's useful to have that as the data is ketpt elsewhere in the db and we would like to offer the user the ability to choose if they want to delete that other data too. Maybe it can be done via a confirmation box with 3 options: delete only data at hand, delete that data + the other data or ignore/cancel dialogue box?
Hi @dynasoft ,
I see. One thing you could do is have another Editor instance, similar to this example here. In your case, you could have a custom button that generates a different edit form with those checkboxes, which after submission, you call
remove()
.Hope that helps,
Cheers,
Colin
Hi
Thanks. I have modified the code Please see below:
I get the form below:
I'd like to be able to place some text between the 2 horizontal line and a (red) delete button where the arrow points to but I'm not sure how to achieve this. Many thanks.
I don't think that will work as you are thinking. That is coring a
create
rather than a delete, which is effectively going to just duplicate the row. There is no delete action going to be performed there.The key thing to do here is to add a little bit of information in what is sent to the server. The
preSubmit
method is the way to do that - e.g.Then you can use
deleteRelated
on the server to decide what you want to do with the other information (keep or remove).So the next question is, how to get a value for that - the
displayOrder
method can be used for that. Add a check in an event handler for that forremove
action, and if so then add in a custom checkbox (the Editor fields are not shown on delete). Then in yourpreSubmit
query that checkbox to get the value.Allan
Many thanks. This is helpful.