0

嗨,我在 jqGrid 中使用自定义格式化程序,它将链接和类添加到列。我将调用的类的名称是“iframe”,它将使用 jquery colorbox 设置我自己的对话框。我在萤火虫中看到列名的类被设置为“iframe”,但是当我点击它时,对话框没有工作。我做错了吗?

<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
$(".iframe").colorbox({ iframe: true, width: "40%", height: "80%", onClosed:function(){ location.reload(true); }  });

jQuery("#MyDynamicGrid").jqGrid({
        url: '/RepositoryRole/DynamicGridData/',
        mtype: 'POST',
        datatype: 'json',
        colModel: [                
            { name: 'Name', index: 'Name', width: 0, align: 'left', searchoptions: { sopt: ['cn', 'eq', 'ne'] }, formatter: returnMyLink, editable: true, editrules: { required: true, edithidden: true }, hidden: false },
            { name: 'Description', index: 'Description', width: 80, align: 'left', searchoptions: { sopt: ['cn', 'eq', 'ne'] },  },                
        ],

        colNames: ['Name', 'Description'],
        pager: jQuery('#pager'),
        rowNum: 5,
        rowList: [5, 10, 20, 30],
        sortname: 'Name',
        sortorder: 'Desc',
        viewrecords: true,
        imgpath: '/Content/JqGridThemes/steel/images',            
        autowidth: true,
        editurl: '/User/EditGrid/'
    });

function returnMyLink(cellValue, options, rowdata, action) {
    return '<a href="#" class="iframe">' + cellValue + '</a> ';
}});

谢谢

4

1 回答 1

0

我认为颜色框没有附加到从 jqgrid 加载的元素上。您可以使用gridComplete重新附加颜色框

jQuery("#MyDynamicGrid").jqGrid({
        url: '/RepositoryRole/DynamicGridData/',
        mtype: 'POST',
        datatype: 'json',
        colModel: [                
            { name: 'Name', index: 'Name', width: 0, align: 'left', searchoptions: { sopt: ['cn', 'eq', 'ne'] }, formatter: returnMyLink, editable: true, editrules: { required: true, edithidden: true }, hidden: false },
            { name: 'Description', index: 'Description', width: 80, align: 'left', searchoptions: { sopt: ['cn', 'eq', 'ne'] },  },                
        ],

        colNames: ['Name', 'Description'],
        pager: jQuery('#pager'),
        rowNum: 5,
        rowList: [5, 10, 20, 30],
        sortname: 'Name',
        sortorder: 'Desc',
        viewrecords: true,
        imgpath: '/Content/JqGridThemes/steel/images',            
        autowidth: true,
        editurl: '/User/EditGrid/',
        gridComplete: function(){
        $(".iframe").colorbox({ iframe: true, width: "40%", height: "80%",       onClosed:function(){ location.reload(true); }  }
       }
    });
于 2011-12-02T05:36:09.580 回答