JqG​​rid:如何从onCellSelect事件获取所有列值? [英] JqGrid: How to get all column values from onCellSelect event?

查看:180
本文介绍了JqG​​rid:如何从onCellSelect事件获取所有列值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用JqGrid生成报告的ASP.NET mvc项目.为了生成报告,我正在生成2种不同的报告.将根据第一份报告"的值生成第二份报告. 为了获取列值,我使用了JqGrid的OnCellSelect事件,

I am developing an ASP.NET mvc project which uses JqGrid for generating report. For report generation i am generating 2 different reports . Second report will be generated based on the values of First report. For getting column values i am using OnCellSelect event of JqGrid,

事件:

$('#Report1').jqGrid({
...
..
colNames: ['name1','name2','name3','name4','name5','name6','name7'],
                        colModel: [
                        {....},
                        { ... },
                        { ...},
                        {...},
                        { ...},
                        { ...},
                        { ... }
                    ],
                        jsonReader: {
                            root: 'DD_data',
                            id: 'name1',
                            repeatitems: false
                        },
                        pager: $('#pager'),
//Event fires when clicked on name7
onCellSelect: function (rowid, index, contents, event) {   

//Code for generating Second Report based on First report data//
$('#Report2').jqGrid({
...
...
});
} 
});

在单元格选择"事件中,我仅获得rowid,我的密钥和选定的单元格内容.

Here in Cell Select event i am only getting rowid , my key , and selected cell content.

但是我还需要选定列中的name2,name3和name4数据来生成第二个报告.

But i also need name2,name3 and name4 data from the selected column to generate second Report.

在JqGrid中可以吗?

Is it possible in JqGrid.

感谢您的帮助.

推荐答案

您可以使用getCellgetRowData从基于rowid的行中获取数据.如果使用datatype: "local"或在网格#Report1中使用loadonce: true选项,则可以使用getLocalRow,它比getRowData有一些优势,但是仅当数据保存在内部参数.仅当datatype不是"json""xml""json""xml",但使用loadonce: true选项时,才会填充参数.

You can use getCell or getRowData to get the data from the row based on rowid. If you use datatype: "local" or if you use loadonce: true option in the grid #Report1 then you can use getLocalRow which have some advantages over getRowData, but works only if the data are saved locally inside of internal data parameter. The parameter will be filled only if datatype is not "json" or "xml" or if it's "json" or "xml", but loadonce: true option are used.

您可以使用的最简单的代码是

The simplest code which you can use would be

onCellSelect: function (rowid) {
    var rowData = $(this).jqGrid("getRowData", rowid);
    // now you can use rowData.name2, rowData.name3, rowData.name4 ,...
}

使用getLocalRow可能具有一些优势(包括性能优势),但是您应该验证它是否可以与在网格#Report1中使用的datatypeloadonce一起使用.

Usage of getLocalRow could have some advantages (including performance advantage), but you should verify whether it works together with datatype and loadonce which you use in the grid #Report1.

这篇关于JqG​​rid:如何从onCellSelect事件获取所有列值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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