开发者

jQuery Grid - Add "Delete" Button

开发者 https://www.devze.com 2022-12-09 19:44 出处:网络
I am using jqgrid to display a nice grid that is filled over a php script. Now I only see the navigation bar, how can I add a \"Delete-Button\" to the left of my bar, so the user can select and delete

I am using jqgrid to display a nice grid that is filled over a php script. Now I only see the navigation bar, how can I add a "Delete-Button" to the left of my bar, so the user can select and delete custom entries (and the jqGrid notifies a php script to delete the selection)?

I only want a delete button, no "Add" button.

Thanks :)

EDIT:

This code is not working. Where's my error?

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


Try something like this:

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


Take a look at: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_buttons. There is an example of what you are looking to do.

0

精彩评论

暂无评论...
验证码 换一张
取 消