var windowId,proName = window.location.pathname.split("/")[1],sysUrl = "http://"+window.location.host+"/"+proName,toEdit;
var winId	= $.getUrlParam("winId");
var obj = top.$("#"+winId).panel("options").data;
$(function(){
	initDefault();	
});
//默认
function initDefault(){
	initGrid();
}
//查询条件
function getQueryParams(){
	var sParam = {};
	sParam.detectortype=obj.deviceType;
	if(obj.type=="1"){//在线
			sParam.tableparam = " and state =1 ";
	}else {
			sParam.tableparam ='and (state=0  or state is null) ';
	}
	sParam.LIKEname= $("#LIKEname").textbox("getValue");
	sParam.order = "order by updatetime desc ";
	return sParam;
}
//加载列表
function initGrid(){	
	var toolbar = [{
    	text	:	'查询',
        iconCls	:	'icon-search',
        handler	:	doSearch
    }];	
	$('#tableGrid').datagrid({
		toolbar : toolbar,
		singleSelect:true,
		rownumbers:true,
		queryParams:getQueryParams(),
		url : "detectorAction!getALLDetetorStatusData.do",
		columns : [[
		    {
				field: 'A',
				checkbox:'true',
				width:30
			},
			{field: 'name', title: '名称', hidden: false, width: 120},
		{field: 'bianma', title: '编码', hidden: false, width: 120},
		{field: 'roadid', title: '道路id', hidden: false, width: 120},
		{field: 'roadname', title: '道路名称', hidden: false, width: 120},
		{field: 'regionid', title: '行政区划编码', hidden: false, width: 120},
		{field: 'regionid', title: '行政区划编码', hidden: false, width: 120},
		{field: 'zt', title: '状态', hidden: false, width: 120},
		]]
	});
}
//查询
function doSearch(){
	$('#tableGrid').datagrid('load',getQueryParams());
}

function transEmpty(str){
	if(!str || str==null ||str=="null"){
		return "-";
	}
	return str;
}