easyUI 定时 刷新 DataGrid

httpMon.js 

$(function(){
	getServiceState();
	run(); 
});

var interval;
function run(){ 
	interval = setInterval(ajaxGetSerState,"3000"); //3秒钟刷一下
} 

function ajaxGetSerState() {
	$.ajax({
		type: 'POST',
		url: $.test.contextPath + '/MonAction.do?method=getState',
		dataType: 'json',
		success: function(data) {
			if ($.isNotEmpty(data) && $.isNotEmpty(data.error)) {
				return;
			}
			  $("#datagrid").datagrid("loadData",data);
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
		}
	});
}

/**
 * 初始化
 */
function getServiceState() {
	$('#datagrid').datagrid({
		url: $.test.contextPath + '/MonAction.do?method=getState',
		striped: true,
		collapsible: true,
		remoteSort: false,
		fit: true,
		fitColumns: true,
		singleSelect: true,
		pageNumber: 1,
		nowrap:false,
		pageSize: 10,
		pagination: false,
		columns : [ [  {
			field : 'serviceName',
			title : '名称',
			width : 70,
			align:'left',
			formatter : function(value, row, index) {
				return row.serviceName;
			}
		}, {
			field : 'serviceState',
			title : '状态',
			width : 270,
			align:'left',
			editor: {
                type: 'validatebox',
                	options: { required: true } 
            },
			formatter : function(value, row, index) {
				if(row.serviceState == 200){
					return row.serviceState;
				}else{
					return  "<div style=\"width: 908px;margin:0 auto;border:red 0px solid;display:block;word-break: break-all;word-wrap: break-word;color:red \">"+row.serviceState+"</div>";
				}
			}
		}
		] ],
		rownumbers: true,
		onLoadSuccess: function(data){
		}
	});
}

 jsp:

<body>
	<div id="toolbar" style="padding: 1px; height: auto;">
		<!-- 查询 -->
		<div>
			<form id="queryForm" method="post" novalidate>
				<table
					style="margin-top: 2px; border: none; border-collapse: collapse; border-spacing: 50px;">
					<tr>
						<td><a href="javascript:void(0)"
							class="button button-rounded button-flat-primary"
							οnclick='getServiceState();'> <i
								class="icon-ccw icon-padding-right5"></i>手动刷新 </a>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	<table id="datagrid" class="easyui-datagrid"  style="width: 100%; height: 100%"
		data-options="width:800,height:500,idField:'keyid',
                      iconCls:'icon-tip',striped: true,fitColumns:true,singleSelect:true,
                      maximized:true,remoteSort: false,rownumbers:true"></table>
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/pages/monitor/httpMon.js"></script>
</body>

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值