Search code examples
ajaxjquery-jtable

How can we send field in Delete Action which are not Key


I need to send fields in delete action which are not tagged as Key. As in my Case I want to delete a row using Multiple fields.


Solution

  • I found answer of it. We need to add this code in field section of jtable

    customDelete: {
        title: '',
        width: '0.3%',
        display: function(data) {
        var $but = $('<button title="delete" class="jtable-command-button jtable-delete-command-button" >delete</button>');
                   $but.click(function(){
                       var $dfd = $.Deferred();
                       if(data.record.configType == 'global')
                       {
                           alert('Global Type Configuration are not allowed for deletion.')
                           return false;
                       }
                       if (confirm('Are you sure you want to delete this?')) {
                             $.ajax({
                                url: '/admin/configuration/delete',
                                type: 'POST',
                                dataType: 'json',
                                data: data.record,
                                success: function (data) {
                                    $dfd.resolve(data);
                                    $('#Container').jtable('load') ;
    
                                },
                                error: function () {
                                    $dfd.reject();
                                }
                            });
                    }
                });
                return $but;
            }
        },
    }