带有Fancybox的JqGrid-获取单元格对象 [英] JqGrid with Fancybox - get cell object

查看:114
本文介绍了带有Fancybox的JqGrid-获取单元格对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jqGrid中使用以下内容:

 colModel: [
            {name:"",index:"",width:100},
            {name:"diagnosis",index:"diagnosis",width:100,formatter:fancyBoxFormatter},
            {name:"prescription", index:"prescription",width:100,formatter:fancyBoxFormatter}, 
            {name:"tests",index:"tests",width:100,formatter:fancyBoxFormatter},
            {name:"imaging",index:"imaging",width:100,formatter:fancyBoxFormatter},
            {name:"generic",index:"generic",width:100,formatter:fancyBoxFormatter},
            {name:"referral",index:"referral",width:100,formatter:fancyBoxFormatter},
            {name:"management",index:"management",width:100,formatter:fancyBoxFormatter},
            {name:"completed",index:"completed",width:100}
            ], 

然后:

function fancyBoxFormatter(cellvalue, options, rowObject) {

    var result,
        link,
        fancyBoxHTML,
        fancyBoxContent;

    link = "<a class=\"fancybox\" href=\"#data" + options.rowId + "\">" + cellvalue + "</a>";
    fancyBoxContent = cellvalue;
    fancyBoxHTML = "<div style=\"display:none\"><div id=\"data" + options.rowId + "\">" + fancyBoxContent + "</div></div>";
    return link + fancyBoxHTML;
}

这将在Fancybox中为行中的所有单元格显示相同的内容(基于rowID ...).如何将此功能更改为单个单元格ID,而不仅仅是整个行?

This displays the same content in Fancybox for all cells in the row (based on rowID...) How can I change this function to individual cell IDs, rather than just the whole row?

推荐答案

请在所有有关jqGrid的问题中写下您使用(可以使用)的jqGrid的版本叉子(您使用的是免费jqGrid ,商业

Please write in all questions about jqGrid the version of jqGrid, which you use (can use) and the fork which you use (free jqGrid, commercial Guriddo jqGrid JS or an old jqGrid in version <=4.7).

自定义格式化程序fancyBoxFormatteroptions参数包含rowIdcolModelgidposrowData属性(rowData仅存在于免费的jqGrid fork中).因此,您可以使用例如

The options parameter of the custom formatter fancyBoxFormatter contains rowId, colModel, gid, pos and rowData properties (rowData exists only in free jqGrid fork). Thus you can use, for example,

function fancyBoxFormatter (cellvalue, options) {
    return "<a class=\"fancybox\" href=\"#data" +
        options.rowId + "_" + options.colModel.name + "\">" + cellvalue + "</a>" +
        "<div style=\"display:none\"><div id=\"data" +
        options.rowId + "_" + options.colModel.name + "\">" +
        cellvalue + "</div></div>";
}

此外,您还必须修复第一列的name属性.一个人不能使用空的name(请参阅name:"").您可以为name使用 any 唯一值,以保存HTML5/CSS中存在的ID规则(例如,没有空格).

Additionally you have to fix the name property of the first column. One can't use empty name (see name:""). You could use any unique value for name holding the rules existing in HTML5/CSS for ids (for example no spaces).

我建议您另外从所有列中删除不需要的index属性和常见的width:100选项.您可以使用jqGrid的cmTemplate: {width: 100}选项来代替在每一列中放置width:100.

I'd recommend you additionally to remove unneeded index properties and common width:100 option from all columns. Instead of placing width:100 in every column you can use cmTemplate: {width: 100} option of jqGrid.

这篇关于带有Fancybox的JqGrid-获取单元格对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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