简体   繁体   English

JQgrid从另一列访问值

[英]JQgrid accessing value from another column

I'm using JQgrid to draw a table in my jsp. 我正在使用JQgrid在我的jsp中绘制表格。 For one of the columns, I have a custom formatter: 对于其中一列,我有一个自定义格式化程序:

function profileConsentFmatter (cellvalue, options, rowObject)
{
    if (options.colModel[12] == "CORPADMIN") {
        return "Company Admin";
    } else if (cellvalue == "true") {
        return "Yes";
    } else {
        return "Pre GDPR";
    }
}

As you can see, I want the value of this column, to depend on the value of another column. 如您所见,我希望此列的值取决于另一列的值。 How do I do that? 我怎么做? I tried different methods from the documentation and they don't seem to work. 我尝试了与文档不同的方法,但它们似乎不起作用。

You can use the rowObject parameter. 您可以使用rowObject参数。 It has all the data for that row but the rowObject format depends on the format of data it received from the server. 它具有该行的所有数据,但rowObject格式取决于它从服务器接收的数据格式。

function profileConsentFmatter (cellvalue, options, rowObject)
{
    if (rowObject.AdminType == "CORPADMIN") {//assuming JSON here
        return "Company Admin";
    } else if (cellvalue) {
        return "Yes";
    } else {
        return "Pre GDPR";
    }
}

This should work. 这应该工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM