jQuery Grid - 添加“删除”按钮

时间:2009-11-01 17:53:50

标签: jquery jqgrid

我正在使用jqgrid显示一个填充在php脚本上的漂亮网格。 现在我只看到导航栏,如何在栏的左侧添加“删除按钮”,以便用户可以选择和删除自定义条目(并且jqGrid通知php脚本删除选择)?

我只想要一个删除按钮,没有“添加”按钮。

谢谢:)

编辑:

此代码无效。哪里是我的错误?

/* List for Update Commands */
  jQuery("#updatelist").jqGrid({
    url:'index.php?list=update',
    datatype: 'xml',
    mtype: 'GET',
    colNames:['ID','URL', 'Limit','Executed','Version'],
    colModel :[ 
      {name:'id', index:'id', width:30}, 
      {name:'url', index:'url', width:290}, 
      {name:'limit', index:'limit', width:50, align:'right'}, 
      {name:'executed', index:'executed', width:70, align:'right'}, 
      {name:'note', index:'note', width:150, sortable:false} 
    ],
    pager: '#updatepager',
    rowNum: 10,
    height:'100%', 
    rowList:[10,20,30],
    sortname: 'id',
    sortorder: 'desc',
    viewrecords: true
  });

jQuery("#updatelist").navGrid('#updatepager',{ edit:false,add:false,del:false,search:false }).navButtonAdd('#updatepager',{ caption:"Add", buttonimg:"js/style/row-insert-under.gif", onClickButton: function(){ var datarow = {name1: value1, name2: value2', ...}; var su=jQuery("#updatelist").addRowData("X",datarow,"last"); if(su) { jQuery("#updatelist").setSelection('X') }; }, position:"last" });

2 个答案:

答案 0 :(得分:2)

尝试这样的事情:

        /* List for Update Commands */
      jQuery("#updatelist").jqGrid({
        url:'index.php?list=update',
        datatype: 'xml',
        mtype: 'GET',
        colNames:['ID','URL', 'Limit','Executed','Version'],
        colModel :[ 
          {name:'id', index:'id', width:30}, 
          {name:'url', index:'url', width:290}, 
          {name:'limit', index:'limit', width:50, align:'right'}, 
          {name:'executed', index:'executed', width:70, align:'right'}, 
          {name:'note', index:'note', width:150, sortable:false} 
        ],
        pager: '#updatepager',
        rowNum: 10,
        height:'100%', 
        rowList:[10,20,30],
        sortname: 'id',
        sortorder: 'desc',
        viewrecords: true
      }).navGrid('#pjmap',{view:true,edit:false,add:false,del:false,search:false})
        .navButtonAdd('#updatepager',{
        caption:"",
        title:"Create new log entry", 
        buttonicon:"ui-icon-plus", 
        onClickButton: function(row_id){ 
            alert("You can add your function here");
        },
        position:"first"
  });

答案 1 :(得分:0)

看看:http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_buttons。有一个你想要做的例子。

相关问题