加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

jqgrid ajax加载

发布时间:2020-12-16 03:17:04 所属栏目:百科 来源:网络整理
导读:第一种local //初始化 var _getData = function () { _putGrid(); $.ajax({ url :urlPath.kafkaMonitorUrl,dataType : 'json' , //type : "POST", async : false ,success : function (result) { if (result[ "code" ] === 200 ){ _putGrid(result[ "Result"

第一种local

//初始化
    var _getData = function(){
        _putGrid();
        $.ajax({
            url :urlPath.kafkaMonitorUrl,dataType :'json',//type : "POST",
            async : false,success : function(result) {
                if (result["code"] === 200){
                    _putGrid(result["Result"]);
                }else {
                    Messager.alert({
                          Msg: result["msg"],iconImg: "warning",isModal: false
                     });
                }
            }
        });
    };

    //数据装入表格
    var _putGrid = function (gridData) {
        //加载jar包列表
        $("#moduleListTable").jqGrid({
            //url : urlPath.kafkaMonitorUrl,
            //mtype : "POST",
            //datatype : "JSON",
            datatype : "local",data : gridData,colModel : [ {
                label : "Id",name : "moduleId",key : true,hidden : true
            },{
                label : "协议类型",name : "topic",sortable:true,align:"center"
            },{
                label : "当前接入速度",name : "BytesOutPerSec",{
                label : "当前接入量",name : "BytesOutCount",{
                label : "历史接入量",name : "BytesOutPerDay",align:"center"
            }
            ],loadonce : false,forceFit: true,viewrecords : true,autowidth : true,height : false,rownumbers : true,multiselect : false,multiboxonly : true,rowNum : 10,// 每页显示记录数
            rowList : [10,15,20 ],// 用于改变显示行数的下拉列表框的元素数组
            pager : "#moduleListPage"
        });
        $("#moduleListTable").jqGrid({autowidth:false}).setGridWidth($(window).width()-300);     
    };
    var _reloadGrid = function(){
        $("#moduleListTable").trigger("reloadGrid")
    };

第二种直接装

initialization:function () {
            $("#systemNoticeTabel").jqGrid({
                url : systemNotice.config.systemNoticeInitializationUrl,mtype : "POST",datatype : "JSON",sortorder: "desc",colNames : ["公告标题","公告类型","公告内容","发布时间","状态"],colModel : [
                            {name:"title",index:"title",align:"center",width:"30px",formatter:function(cellvalue,options,rowObject){
                                    var titleType = "";
                                    if(1 == rowObject.important){
                                        titleType = "<font color=red>★</font>"+cellvalue;
                                    }else{
                                        titleType = cellvalue;
                                        }
                                    return titleType;
                            }},{name:"important",index:"important",width:"20px",rowObject){
                                    var type = "";
                                    if(0 == cellvalue){
                                        type = "一般公告";
                                    }else if(1 == cellvalue){
                                        type = "重要公告";
                                    }
                                    return type;
                                }
                            },{name:"content",index:"content",sortable:true},{name:"createTime",index:"create_time",{name:"status",index:"4",hidden : true,sortable:false}
                            ],/*表格加载完成后执行的函数*/
                gridComplete:function(){
                    var rowids = $("#systemNoticeTabel").jqGrid('getDataIDs');
                    for(var i = 0;i < rowids.length; i++){
                    var allrowIds = [];
                    allrowIds[i]=rowids[i];
                    var allrowDatas = $("#systemNoticeTabel").jqGrid('getRowData',rowids[i]);
                    var allrowdatStatus = allrowDatas.status;
                    if(allrowdatStatus == "140001001"){
                        $("#"+allrowIds[i]).find("td").css("color","red");
                        $("#"+allrowIds[i]).find("td").css("font-weight","bold");
                    }else{
                        $("#"+allrowIds[i]).find("td").css("color","#333");
                        $("#"+allrowIds[i]).find("td").css("font-weight","normal");
                    }   
                    }
                },multiselect : true,// 每页显示记录数
                rowList : [10,// 用于改变显示行数的下拉列表框的元素数组
                pager : "#systemNoticePage",});
            //jqGrid自适应宽度 
          $(window).resize(function(){     
                $("#systemNoticeTabel").jqGrid({autowidth:false}).setGridWidth($(window).width());
            });

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读