Joper
Joper

Reputation: 8219

How to remove inline delete action in JQGrid

I was trying to modify the sample from that question Custom jQGrid post action http://ok-soft-gmbh.com/jqGrid/TestSamle/Admin1.htm to remove delete action like that:

ondblClickRow: function (id, ri, ci) {
                    //...
                    $("div.ui-inline-edit", tr).hide();
                    //...
                }, 

onSelectRow: function (id) {
                    //...
                        $("div.ui-inline-edit", tr).show();
                    //...
                    }



  loadComplete: function () {
      $("div.ui-inline-del", tr).hide();
    }

But does not help.

Any ides how i can do that?

Upvotes: 2

Views: 8543

Answers (3)

Anderson
Anderson

Reputation: 146

What about formatoptions:{..., delbutton:false, ...} ?

http://www.trirand.net/documentation/php/_2v70wa4jv.htm

Upvotes: 12

Oleg
Oleg

Reputation: 222007

It seems to me that you should first hide all "del" icons inside of loadComplete and then add afterSave and afterRestore property to the formatoptions of the actions formatter:

formatter: 'actions',
formatoptions: {
    keys: true, // we want use [Enter] key to save the row and [Esc] to cancel editing
    afterSave: hideDelIcon,
    afterRestore: hideDelIcon
}

where

var hideDelIcon = function(rowid) {
        setTimeout(function() {
            $("tr#"+$.jgrid.jqID(rowid)+ " div.ui-inline-del").hide();
        },50);
    };

See the modified demo here.

Upvotes: 1

kleinohad
kleinohad

Reputation: 5912

you can add this:

 $('.ui-inline-del').each(function(index) {
                        $(this).html('');
                        });
or this:
$('.ui-inline-del').each(function(index) {
                    $(this).hide();
                    });

at the end of loadComplete: function () { also change

.jqGrid('navGrid', '#Pager1', { add: true, edit: false }, {}, {},
                  myDelOptions, { multipleSearch: true, overlay: false });

to:

.jqGrid('navGrid', '#Pager1', { add: true, edit: false, del:false }, {}, {},
                  myDelOptions, { multipleSearch: true, overlay: false });

if you wish to remove the row delete option in the footer

Upvotes: 1

Related Questions