jquery – jqGrid中的图像列?

前端之家收集整理的这篇文章主要介绍了jquery – jqGrid中的图像列?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想要在我的jQGrid中的一个图像列,我使用了一个格式化程序,但不工作,请给我解决方案.

我的代码如下:

jQuery(document).ready(function() {
        var TheGrid ;
         var resp;
        jQuery("#registerUsers").jqGrid({
                url: 'EventsList.aspx',datatype: "json",colNames: ['Name','Company Name','Responsible Name','Date/Time','Id'],colModel: [{ name: 'GuestName',index: 'GuestName',width: 150,editable: true,editoptions: {readonly: true,size: 10} },{ name: 'CompName',index: 'CompName',editable: false,editoptions: { readonly: true,{ name: 'RespName',index: 'RespName',{ name: 'RegisterDate',index: 'RegisterDate',{ name: 'Register_Id',index: 'Register_Id',width: 100,align: 'left',formatter: checkBoxFormatter },],rowNum: 10,rowList: [10,20,30],pager: jQuery('#Userpager'),sortname: 'Register_Id',viewrecords: true,sortorder: "desc",imgpath: '/scripts/themes/steel/images',caption: "Registered Users"
            });
        });
        jQuery("#registerUsers").jqGrid('navGrid','#Userpager',{ edit: false,add: false,del: false });

  function checkBoxFormatter(el,cval,opts) {
            debugger;
            cval = cval + ""; cval = cval.toLowerCase();
            //          var bchk = cval.search(/(false|0|no|off|n)/i) < 0 ? " checked=\"checked\"" : ""; 
            var UserId = jQuery("#registerUsers").getCell(RowId,'Register_Id');
            $(el).html("<center><img src='../images/gnome-session-logout.png' width='15px' height='15px'  onclick=javascript:logoutUser(" + UserId + ");/></center>");
            //          <input type='checkBox' onclick=\"ajaxSave('" + opts.rowId + "',this);\" " + bchk + " value='" + cval + "' offval='no' />



        }

请帮帮我

谢谢
丽思

解决方法

您可以将img标签作为字符串返回格式化程序,例如:
function  unitsInStockFormatter(cellvalue,options,rowObject) {
    var cellValueInt = parseInt(cellvalue);
    if (cellValueInt > 10)
      return "<img src='../../Content/images/ui-flag_green.png' alt='" + cellvalue + "'title='" + cellvalue + "' />";
    else if (cellValueInt > 0)
      return "<img src='../../Content/images/ui-flag_blue.png' alt='" + cellvalue + "'title='" + cellvalue + "' />";
    else
      return "<img src='../../Content/images/ui-flag_red.png' alt='" + cellvalue + "'title='" + cellvalue + "' />";
  };

如下所述:
http://tpeczek.com/2009/11/jqgrid-and-aspnet-mvc-formatting.html

原文链接:https://www.f2er.com/jquery/180003.html

猜你在找的jQuery相关文章