how do I change the image in a CellSelect event in jqgrid?

烂漫一生 提交于 2019-12-24 08:04:34

问题


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:

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>";
    }
}

and my method of

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

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


回答1:


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);
},

I hope it helps.



来源:https://stackoverflow.com/questions/7640521/how-do-i-change-the-image-in-a-cellselect-event-in-jqgrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!