【问题标题】:jQuery Grid - Add "Delete" ButtonjQuery Grid - 添加“删除”按钮
【发布时间】:2009-11-01 17:53:50
【问题描述】:

我正在使用 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" });

【问题讨论】:

  • 您只需要导航栏中的单个删除按钮还是每行的删除按钮?

标签: jquery jqgrid


【解决方案1】:

试试这样的:

        /* 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"
  });

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 试过了,不行。用问题描述更新了我的帖子。
    • 顺便说一句 - 我在下面留下的示例是添加按钮,但您可以轻松地将其更改为仅删除按钮。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-10
    • 1970-01-01
    • 2018-01-27
    • 1970-01-01
    • 1970-01-01
    • 2015-12-15
    • 1970-01-01
    相关资源
    最近更新 更多