easyUI 정시 업데이트 DataGrid

3516 단어 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"
							onclick='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>

 

좋은 웹페이지 즐겨찾기