单击自定义按钮获取行数据 [英] Get row data on custom button click

查看:89
本文介绍了单击自定义按钮获取行数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用免费的jqgrid 4.14,我需要在网格中有一个自定义图像(某种邮件图标),当单击该图像时,它应该打开一个具有形式并且包含被点击行数据的模态窗口.在表单的消息字段中,还具有其他几个字段,例如发送者邮件ID,接收者邮件ID以及主题.

I am using free jqgrid 4.14 and I need to have a custom image (some kind of mail icon) in my grid and when the image is clicked it should open a modal window having a form and which has the data of clicked row in the message field of form and also has other couple of field like sender mail id, receiver mail id and also a subject.

因此,我能够在网格中拥有一个自定义图像.现在,我们有了 onSelectRow 属性,通过它可以获取被单击的行的ID,还有 getRowData 将提供列的数据.

So, I was able to have a custom image in my grid. Now, we have onSelectRow property by which we can get the id of the clicked row and we have getRowData which will give the data of the columns.

所以,我对onSelectRow做了这样的更改

So, I made changed onSelectRow a bit like this

onSelectRow: function(id){ 
            if(id && id!==lastSel){ 
                jQuery(this).restoreRow(lastSel); 
                lastSel=id; 
                var rowId = $(this).getRowData(lastSel);
            } 
            jQuery(this).editRow(id, true); 
        }

现在,这将在单击时提供每一行的数据.但是,单击自定义图像后如何获得相同的功能?

Now, this will give the data of each row when it is clicked. But how will I get same functionality when my custom image is clicked?

我需要这样的东西-

http://www.ok-soft-gmbh.com/jqGrid /Admin3.htm

但是在这里我找不到像这里找到的图像

But here I am not able to find the image like here it finding

推荐答案

有很多方法可以实现该要求.我在答案中描述的最简单的一个.您可以使用formatter: "actions"

There are many ways to implement the requirement. One from the easiest one I described in the answer. You can add the column with formatter: "actions"

{
    name: "act", template: "actions", width: 25,
    formatoptions: { editbutton: false, delbutton: false }
}

和jqGrid选项,用于指定其他自定义按钮

and the jqGrid option, which specify additional custom buttons

actionsNavOptions: {
    mailicon: "fa-envelope-o",
    custom: [
        {
            action: "mail",
            position: "first",
            onClick: function (options) {
                alert("Mail for rowid=" + options.rowid);
            }
        }
    ]
}

请参见 https://jsfiddle.net/OlegKi/3tuxg71z/

这篇关于单击自定义按钮获取行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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