如何在jqgrid的CellSelect事件中更改图像? [英] how do I change the image in a CellSelect event in jqgrid?

查看:58
本文介绍了如何在jqgrid的CellSelect事件中更改图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了麻烦,因为在jqgrid的onCellSelect事件中,我想更改单元格的图像,例如,一旦单击单元格内部,我就想要更改图像,如下所示:,我存档的唯一内容是,一旦每个单元格中的网格负载加载了图像,它就会发生变化:

I am having trouble because in a onCellSelect event of the jqgrid I want to change the image of a cell, for example once I click inside the cell I want to change the image like this:, the only thing I have archived It is changing once the grid load in each cell loads an image:

这是我将img加载到网格中的代码:

this is my code for loading the img in the grid:

{display: '', name : '', formatter: image}

function image(cellvalue, options, rowObject){
    if(rowObject[5]== 1){
        return "<span class='ui-icon ui-icon-plusthick'></span>";
    }else{
        return "<span class='ui-icon ui-icon-minusthick'></span>";
    }
}

和我的方法

onCellSelect: function() {
    id = $("#list2").getGridParam('selrow'); 
 }, 

如何归档onCellSelect上的每个单元格的img?

how can I archieve that on a onCellSelect change the img of each cell?

推荐答案

我不确定我是否理解正确,但这是一个示例:

I'm not sure I understand correctly, but here's a sample:

onCellSelect: function(rowid, iCol, cellcontent, e) {
   // Get current row content.
   var data = $(this).jqGrid('getRowData', rowid);

   // Edit the column's content. In this case the one named image.
   data.image = "<span class='ui-icon ui-icon-plusthick'></span>";

   // Set the data back.
   $(this).jqGrid('setRowData', rowid, data);
},

希望对您有帮助.

这篇关于如何在jqgrid的CellSelect事件中更改图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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