var table;
$(function() {
	initTable();
	$("#query_btn").click(function() {
		table.fnDraw();
	});
});

function initTable() {
	if (table == undefined) {
		table = $("#tableList")
				.myDataTable(
						{
							"sAjaxSource" : ctx
									+ '/announcement/queryannouncement1',
							"paramSelector" : '#name',
							"iDisplayLength" : 10,
							"bSort" : false,
							"aoColumns" : [
									{
										"sTitle" : "序列",
										"bSortable" : true,
										sWidth : 100
									},
									{
										"sTitle" : "标题",
										sWidth : 150
									},
									{
										"sTitle" : "内容",
										sWidth : 300
									},
									{
										"sTitle" : "创建时间",
									},
									{
										"sTitle" : "更新时间",
									},
									{
										"sTitle" : "路径",
									},
									{
										"sTitle" : "操作",
										fnRender : function(obj) {
											var id = obj.aData[0];
											return "<a href='"
													+ ctx
													+ "/announcement/queryAnnouncementInfoById?id={0}'>编辑</a>&nbsp|&nbsp"
															.format(id)
													+ "<a href='javascript:deletes({0})'>删除</a>"
															.format(id);
										}
									} ]
						});
	} else {
		table.fnPageChange("first", true);
	}
}
function deletes(id){
	if(confirm('确定删除吗？'))
	  window.location.href=ctx+'/announcement/deleteAnnouncementInfo?id='+id;
}
