使用jqgrid在标题的底部添加工具栏

时间:2010-08-24 01:03:51

标签: jqgrid

我想在标题的底部添加一个带有不同按钮的工具栏。有什么可能吗?

使用

 toolbar: [true,"top"] or toolbar: [true,"bottom"] 

显示相同的工具栏... 在底部工具栏中包含添加,编辑,删除按钮.. 我想在顶部工具栏中进行更改只包含ADD按钮..&底部工具栏包含编辑,删除,刷新等,

谢谢,

2 个答案:

答案 0 :(得分:17)

可能你误解了jqGrid的toolbar参数。如果您另外定义cloneToTop: true jqGrid选项,也许您希望使用Navigator toppager: true。此选项克隆jqGrid顶部的寻呼机div。在此之后,可以轻松地从顶部或底部“工具栏”中删除一些元素:

jQuery("#list").jqGrid({
    // some parameters
    toppager: true,
    // some other paremeters
}).jqGrid('navGrid','#pager',{cloneToTop:true});

var topPagerDiv = $("#list_toppager")[0];
$("#edit_list_top", topPagerDiv).remove();
$("#del_list_top", topPagerDiv).remove();
$("#search_list_top", topPagerDiv).remove();
$("#refresh_list_top", topPagerDiv).remove();
$("#list_toppager_center", topPagerDiv).remove();
$(".ui-paging-info", topPagerDiv).remove();

var bottomPagerDiv = $("div#pager")[0];
$("#add_list", bottomPagerDiv).remove();

将使用上述代码中不同ID名称的“list”部分,因为我们使用id为“list”的<table>元素。

答案 1 :(得分:0)

来自Demo site

HTML

Javascript代码

    jQuery("#myGrid").jqGrid({
  url:'server.php?q=1',
  datatype: "xml",
  colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
  colModel:[
    {name:'id',index:'id', width:55},
    {name:'invdate',index:'invdate', width:90},
    {name:'name',index:'name', width:100},
    {name:'amount',index:'amount', width:80, align:"right"},
    {name:'tax',index:'tax', width:80, align:"right"},      
    {name:'total',index:'total', width:80,align:"right"},       
    {name:'note',index:'note', width:150, sortable:false}       
  ],
  rowNum:10,
  rowList:[10,20,30],
  pager: '#pgmyGrid',
  sortname: 'id',
  viewrecords: true,
  sortorder: "desc",
  caption:"Toolbar Example",
  editurl:"someurl.php",
  toolbar: [true,"top"] //THIS IS IMPORTANT!
  });
  jQuery("#myGrid").jqGrid('navGrid','#pgmyGrid',{edit:false,add:false,del:false});

  $("#t_myGrid").append("<input type='button' value='Click Me' style='height:20px;font-size:-3'/>");