jqgrid 单元格放超链接文本

Posted 听哥哥的话

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jqgrid 单元格放超链接文本相关的知识,希望对你有一定的参考价值。

1.前台
<%-- builed by manage.aspx.cmt  [ver:2016.56.27] at 2016/10/27 11:56:25 --%>


<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="SysExceptionLogManage.aspx.cs" ValidateRequest="false" Inherits="HraWeb.SysExceptionLogManage" %>

<%@ Register Assembly="Trirand.Web" TagPrefix="asp" Namespace="Trirand.Web.UI.WebControls" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">

        <div id="toolbar" class="datagrid-toolbar">
            <span class="title">业务异常类型:</span><input type="text" id="txt_ExceptionType_LK_" name="txt_ExceptionType_LK_" class="input datacontrol" style="width: 100px" />
            <span class="title">业务异常代码:</span><input type="text" id="txt_ExceptionCode_LK_" name="txt_ExceptionCode_LK_" class="input datacontrol" style="width: 100px" />
            <a href="#" id="btn_edit" iconcls="icon-edit" class="button">查看</a>
            <a href="#" id="btn_search" iconcls="icon-search" class="button">查询</a>
        </div>
        <div class=jdataGrid>
            <asp:JQGrid runat="server" ID="jq" AutoWidth="true" Height="400"
                DataUrl="/admin/sys/SysExceptionLogManage.aspx?_method=search">
                <Columns>
                    <asp:JQGridColumn DataField="ModuleId" Visible="true" HeaderText="业务模块ID" Frozen="true"></asp:JQGridColumn>
                    <asp:JQGridColumn DataField="ModuleName" Visible="true" HeaderText="业务模块名称"></asp:JQGridColumn>
                    <asp:JQGridColumn DataField="ExceptionType" Visible="true" HeaderText="业务异常类型"></asp:JQGridColumn>
                    <asp:JQGridColumn DataField="ExceptionCode" Visible="true" HeaderText="业务异常代码"></asp:JQGridColumn>
                    <asp:JQGridColumn DataField="ExceptionReason" Visible="true" HeaderText="异常原因(简述)"></asp:JQGridColumn>
                    <asp:JQGridColumn DataField="ExceptionDetail" Visible="true" HeaderText="异常的详细内容">
                    </asp:JQGridColumn>
                    <asp:JQGridColumn DataField="ExceptionWaning" Visible="true" HeaderText="问题的严重级别"></asp:JQGridColumn>
                    <asp:JQGridColumn DataField="CreateUname" Visible="true" HeaderText="操作人"></asp:JQGridColumn>
                    <asp:JQGridColumn DataField="OperationAction" Visible="true" HeaderText="对应操作(业务操作)"></asp:JQGridColumn>
                    <asp:JQGridColumn DataField="OperationDate" Visible="true" HeaderText="操作时间"></asp:JQGridColumn>
                    <asp:JQGridColumn DataField="Id" Visible="false" PrimaryKey="true"></asp:JQGridColumn>
                </Columns>
                <ClientSideEvents LoadComplete="JDataGrid.loadComplete" RowDoubleClick="JDataGrid.rowDoubleClick" />
            </asp:JQGrid>
        </div>
        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-hidden="true" style="width: 500px; height: 700px; margin-left: 30%;">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        详细信息:
                       <%-- <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>--%>
                    </div>
                    <div class="modal-body" style="height: 300px;">
                        <div id="logs"></div>
                        <button type=button class=btn btn-default btn-sm id=btn_close>关闭</button>

                        <%-- <iframe id="detail" src="" style="width: 870px; height: 460px;"></iframe>--%>
                    </div>
                </div>

            </div>
        </div>
    </form>


    <script type="text/javascript">
        var logMeasage = new Array();
        JDataGrid.rowDoubleClick = function () {

            return false;
        }
        function gridComplete() {
            var jq = $("#jq");
            var ids = jq.jqGrid(getDataIDs);
            for (var i = 0; i < ids.length; i++) {
                var id = ids[i];
                var obj = jq.jqGrid(getRowData, ids[i]);
                var name = obj.Name;
                logMeasage[id] = obj;
                var editBtn = obj.ExceptionDetail.substring(0, 7) + ".." + "<button  class=‘btn btn-primary btn-sm‘ type=‘button‘  id=" + id + " style=‘color:#f60‘ onclick=‘_edit(" + id + ")‘ >详情</button>"; //此处会将点击行id传给_edit(id) js函数
                $("#jq").jqGrid(setRowData, id, { ExceptionDetail: editBtn });
            }
        }
        function _edit(id) {

            var obj = $("#jq").jqGrid(getRowData, id);

            $("#detail").attr("src", "/admin/sys/SysExceptionLogEdit.aspx?Id=" + obj.Id);
            $("#logs").html("");
            $("#logs").prepend("<br>" + logMeasage[id].ExceptionDetail + "!!" + "<p>");
            //$("#txt_ExceptionDetail_").val(obj.ExceptionDetail);
            $(#myModal).modal(show);
        }
        function PageOnLoad() {
            $("#btn_close").on("click", function () {
                $(#myModal).modal(hide);
            });
            //控件按钮设置
            $(".button").linkbutton({ plain: true });
            //参数说明:控件Id,查询地址,编辑页面的宽度,高度,编辑页面标题,新增按钮,编辑按钮,删除按钮,查询按钮,查询回调函数
            JDataGrid.InitGrid("jq", "/admin/sys/SysExceptionLogEdit.aspx", 600, 550, "业务异常日志", $("#btn_add"), $("#btn_edit"), $("#btn_del"), null);
        }
    </script>

</body>
</html>
2.后台
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HraWeb.Common;
using WebApp.Common;
using Contract.Domain;
using System.Collections;
using HRAModel.Sys.Enum;
using Framework;

namespace HraWeb
{
    public partial class SysExceptionLogManage : BootStrapManage<Contract.Domain.SysExceptionLog>
    {
        protected override void Page_Load(object sender, EventArgs e)
        {
            jq.ClientSideEvents.LoadComplete = "gridComplete";

            //给基类服务接口复制,可不付
            //base.svc = Psvc;
            if (!IsPostBack)
            {

            }
            base.Page_Load(sender, e);
        }
        protected override string AddScriptInDoucumentReady()
        {

            return "";
        }

        public override void ChangeList(QueryInfo infoList)
        {
            foreach (SysExceptionLog log in infoList.List)
            {
                if (log.ExceptionDetail.Length > 10)
                {
                   // log.ExceptionDetail = log.ExceptionDetail.Substring(0, 7) + "...详情";
                }

            }
        }
        /// <summary>
        /// 设置查询条件或者语句
        /// </summary>
        /// <returns></returns>
        protected override Framework.QueryInfo SetInfo()
        {
            info = base.SetInfo();
            return info;
        }
        /// <summary>
        /// 初始化页面控件
        /// </summary>
        protected override void InitPage()
        {
            base.InitPage();

            // BindDrop(drp_Unit, "SPSW", true);
        }
        //private Contract.IService.ISysExceptionLogService psvc;
        ///// <summary>
        ///// 初始化
        ///// </summary>
        //Contract.IService.ISysExceptionLogService Psvc
        //{
        //    get
        //    {
        //        if (psvc == null)
        //        {
        //            psvc = ctx.GetObject("SysExceptionLogService") as Contract.IService.ISysExceptionLogService;
        //        }
        //        return psvc;

        //    }
        //}
    }
}

 

以上是关于jqgrid 单元格放超链接文本的主要内容,如果未能解决你的问题,请参考以下文章

ASP.net MVC 代码片段问题中的 Jqgrid 实现

jQgrid单元格编辑最后一个无法自动保存解决办法

单击jqgrid网格时如何仅突出显示单元格

可以用 AddRowData 定义 jqGrid 悬停文本吗?

Jqgrid根据其内容可编辑列宽

怎样获取编辑后的jqgrid的值