获取选定行的列名称jqGrid [英] Get column name of selected row jqGrid

查看:84
本文介绍了获取选定行的列名称jqGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否有办法在jqGrid上获取所选行的列名?例如,在小提琴上: http://jsfiddle.net/5B2Wh/43/

Is there a way for me to get the column name of the selected row on jqGrid? For example, on the fiddle: http://jsfiddle.net/5B2Wh/43/

如果我单击内容为"Merge C"的单元格,它将返回"Client",这是它所在的列名称.

If I clicked on the cell with the content "Merge C", it will return "Client" which is the column name that it is under.

我尝试使用下面的代码,但只发送未定义的代码.

I tried using the code below, but it only sends undefined.

var cm = jQuery("#scrgrid").jqGrid("getGridParam", "colModel");
alert(cm.name);

推荐答案

colModel是一个数组,您必须从中选择相关的列.

colModel is an array, you have to select the relevant column from it.

$("#scrgrid").jqGrid({
    ...
    onCellSelect: function(row, col, content, event) {
        var cm = jQuery("#scrgrid").jqGrid("getGridParam", "colModel");
        alert(cm[col].name);
    }
});

但是,这在您的网格中不起作用,因为您已启用了编辑功能,从而无法选择单元格.

However, this doesn't work in your grid because you have editing enabled, which disables the ability to select cells.

这篇关于获取选定行的列名称jqGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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