2011-07-13 57 views
2

我試圖從這個問題Custom jQGrid post action http://ok-soft-gmbh.com/jqGrid/TestSamle/Admin1.htm修改示例刪除刪除動作這樣的:如何刪除內嵌刪除操作中的jqGrid

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(); 
    } 

但於事無補。

任何ide我怎麼能做到這一點?

回答

1

在我看來,你應該先隱藏loadComplete內的所有「德爾」圖標,然後afterSaveafterRestore屬性添加到actions格式化的formatoptions

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

其中

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

見修改後的演示here

1

,你可以補充一點:在loadComplete: function() { 結束

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

也改變

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

到:

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

如果你想刪除的行中刪除選項頁腳

+1

這太複雜了。只需使用'formatoptions:{...,delbutton:false,...}?'如安德森答案中所述刪除刪除按鈕 – Andrus