0

我在我的应用程序中使用 jqgrid 和 prettyphoto。
我有一列显示图像预览。单击该图像时,该图像将显示在弹出框中。
网格代码是..

.....  
{name: 'imagePath', index: 'imagePath', width: 80, align: 'center',
    formatter :anchorFmatter, edittype: 'text', hidden: false, editable: true,
    editrules: {required: false}, editoptions: {size: 30}}
....
function anchorFmatter(cellValue, options, rowObject)
{
    if(cellValue === null ){
        return "<a></a>";
    }else {
        jQuery("a[rel='image']").prettyPhoto({
            animation_speed:'normal',
            show_title:false,
            allow_resize:true,
            default_width:640,
            default_height:385,
            theme:'light_rounded',
            autoplay:false
        });

        return "<a href='" + cellValue + "' rel='image'><img src='" + cellValue +
               "' width='100' height='35'></a>";
    }
}   

网格中的所有图像都出现在弹出窗口中,但最后一张图像出现在新的浏览器页面中。
可能会得到任何帮助。
提前致谢

4

1 回答 1

1

自定义格式化程序内部,网格包含仍然作为字符串存在并且尚未放置在页面上。因此,您应该jQuery("a[rel='image']").prettyPhoto从 formutter 函数中删除调用。取而代之的是,您可以调用loadComplete事件处理程序的jQuery("a[rel='image']").prettyPhoto内部。此外,如果您尚未使用选项,则应该使用它。它将提高网格性能。gridview:true

于 2011-08-29T10:03:03.580 回答