2

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?

Community
  • 1
  • 1
Joper
  • 8,019
  • 21
  • 53
  • 80

3 Answers3

12

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

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

Anderson
  • 146
  • 3
1

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

kleinohad
  • 5,800
  • 2
  • 26
  • 34
  • 1
    This is too complicated. simply using `formatoptions:{..., delbutton:false, ...} ?` as stated in Anderson answer removes delete button – Andrus Aug 15 '11 at 15:05
1

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.

Oleg
  • 220,925
  • 34
  • 403
  • 798