Conditional DELETE
Conditional DELETE
nskwortsow
Posts: 120Questions: 0Answers: 0
Hi,
How would I show a DELETE button conditionally, based on the value of a (hidden) field?
E.g.
you cannot delete a user who has already logged in.
> where do I set the value (hidden) when the user last logged in
> how do I conditionally show the Delete button?
Thanks.
How would I show a DELETE button conditionally, based on the value of a (hidden) field?
E.g.
you cannot delete a user who has already logged in.
> where do I set the value (hidden) when the user last logged in
> how do I conditionally show the Delete button?
Thanks.
This discussion has been closed.
Replies
This selector is what you could use to get the delete button:
[code]
$('a.DTTT_button').filter(":contains('Delete')")
[/code]
So the extension would be:
[code]
$('a.DTTT_button').filter(":contains('Delete')").css( 'display', data.loggedIn ? 'none' : 'block' );
[/code]
Allan
I trigger my editor with a .on("click",...) event. Ideally, I could test the condition of the value of this hidden field before showing the delete button?
What do you suggest?
Which is presumably feed from your row's data source in the DataTable? So fnGetSelectedData will allow you to access that property. `row.lastlogindate` for example.
> I trigger my editor with a .on("click",...) event. Ideally, I could test the condition of the value of this hidden field before showing the delete button?
I don't really understand - are you not using a 'Delete' button in TableTools like that which is typically used in the examples?
Allan
It shows three buttons.
Where & when would I call the code to hide the delete button if row.lastlogindate NOT NULL?
/N
[code]
$('#tblOne tbody').on('click', function(e)
{
var $target = $(e.target);
if ($target.hasClass('btn'))
{
// removed
else
{
var $parent = $(e.target).parent();
//console.log($parent[0]);
editor.title('Edit');
editor.edit($parent[0]);
editor.buttons([
{
"label": "Cancel",
"className": "btn btn-link",
"fn": function()
{
editor.close();
}
}, {
"label": "Delete",
"className": "btn btn-inverse pull-left",
"fn": function()
{
this.remove($parent[0], 'Delete?', {
"label": "Confirm",
"className": "btn",
"fn": function()
{
this.submit();
}
});
}
}, {
"label": "Save",
"className": "btn",
"fn": function()
{
editor.submit();
}
}]);
}
});
[/code]
Allan