2011-07-13 32 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