免费的jgGrid在分页器上显示添加按钮 [英] Free jgGrid show add button on pager

查看:123
本文介绍了免费的jgGrid在分页器上显示添加按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置一个简单的jqGrid,将进行内联编辑和删除,但是现在尝试使添加按钮显示在寻呼机上.我将从默认的添加操作开始,但是我似乎不记得如何在其中显示添加按钮,而且我想知道在免费jqGrid上执行此操作的简洁方法.

I am setting up a simple jqGrid, and will have inline editing and deleting, but now trying to make the add button show up on the pager. I will start with the default add action, but I can't seem to remember how to make the add button show there, and I would like to know the clean way to do it on free jqGrid.

这是当前代码.谢谢.

$('#press_op_setup').jqGrid({
        url:'grid.php',
        postData:{
            'arg1':'press_ops'
        },
        height: 'auto',
        datatype: 'xml',
        mtype: 'POST',
        width: 400,
        colNames:[
            'id',
            'Emp Num'
        ],
        colModel:[
            {name: 'id', hidden: true, key: true},
            {name: 'empnum'}
        ],
        inlineEditing: {addRow: {}},
        sortname: 'empnum',
        sortorder: 'asc',
        viewrecords: true,
        gridview: true,
        caption: 'Press Operators',
        rowNum: 100,
        pager: true
    });
})

推荐答案

我不确定我是否正确理解您的需求.您应该至少调用inlineNav方法,或者同时调用navGridinlineNav.您可以在创建网格后直接调用方法.使用navOptionsinlineNavOptions,您可以指定navGridinlineNav的其他选项.另外,您可以直接使用与navGridinlineNav方法的选项相同的选项.

I'm not sure that I correctly understand what you need. You should call at least inlineNav method or both navGrid and inlineNav. You can call the methods directly after creating the grid. Using navOptions and inlineNavOptions you can specify additional options of navGrid and inlineNav. Alternatively you can use the same options directly as the options of navGrid and inlineNav methods.

一件事情用简单的方法是行不通的:在导航栏(寻呼机)内对按钮进行重新排序.您仍然可以使用appendprepend等jQuery方法移动DOM元素.例如,您的代码可能如下:

One thing with isn't work in simple way: reordering of buttons inside of navigator bar (pager). You still can move the DOM elements using jQuery methods like append, prepend and so on. For example, your code could be the following:

$('#press_op_setup').jqGrid({
    url:'grid.php',
    postData:{
        'arg1':'press_ops'
    },
    datatype: 'xml',
    mtype: 'POST',
    width: 400,
    colNames:[
        'id',
        'Emp Num'
    ],
    colModel:[
        //{name: 'id', hidden: true, key: true},
        {name: 'empnum'}
    ],
    inlineEditing: { keys: true },
    sortname: 'empnum',
    sortorder: 'asc',
    viewrecords: true,
    caption: 'Press Operators',
    rowNum: 100,
    pager: true,
    navOptions: { add: false, edit: false, search: false, refresh: false },
    inlineNavOptions: { add: true, edit: true }
}).jqGrid("navGrid")
    .jqGrid("inlineNav");
$("#press_op_setup_iladd").prependTo($("#press_op_setup_iladd").parent());

我删除了不需要的隐藏id列.行(<tr>元素)的id属性将被设置.不需要将相同信息的副本保存在网格的隐藏<td>元素中.

I removed unneeded hidden id column. The id attribute of rows (<tr> elements) will be set already. One don't need to hold the copy of the same information in hidden <td> element of the grid.

我删除了不需要的height: 'auto'gridview: true选项,这是免费jqGrid的默认选项.也不需要inlineEditing中的空addRow: {}.您应该仅指定属性,您确实需要像上面的keys: true那样设置.

I removed unneeded height: 'auto' and gridview: true options, which are default for free jqGrid. Empty addRow: {} inside of inlineEditing is unneeded too. You should specify only the properties, which you really need to set like keys: true above.

这篇关于免费的jgGrid在分页器上显示添加按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆