<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Unit.aspx.cs" Inherits="XpShop.Manage.Unit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
	<HEAD>
	    <meta http-equiv="content-type" content='text/html;charset=utf-8'/>
		<title>单位管理</title>
		<link rel="stylesheet" href="style/main.css" type="text/css"/>
        <link href="inc/jqgrid/css/jquery-ui-1.7.1.custom.css" rel="stylesheet" type="text/css" />
        <link href="inc/jqgrid/css/ui.jqgrid.css" rel="stylesheet" type="text/css" />
        <link href="inc/jqgrid/css/ui.multiselect.css" rel="stylesheet" type="text/css" />
        <link href="inc/popup/jquery.popup.css" rel="stylesheet" type="text/css" />
        <script src="inc/jqgrid/jquery-1.4.2.min.js" type="text/javascript"></script>
        <script src="inc/jqgrid/grid.locale-cn.js" type="text/javascript"></script>        
        <script src="inc/jqgrid/jquery.jqGrid.min.js" type="text/javascript"></script>
        <script src="inc/popup/jquery.popup.js" type="text/javascript"></script>
        <script src="inc/jqgrid/setPager.js" type="text/javascript"></script>
        <script src="inc/pngpic.js" type="text/javascript"></script>
        <script src="inc/commond.js" type="text/javascript"></script>
        <script type="text/javascript">
        $(document).ready(function(){
            var ph = $(window.parent.frames.right).height()-$('div.sub_container_title').height()-100;
            $("#list").jqGrid({
				url: 'ajax.ashx?nocopyright=1&Action=GetUnits',//地址文件
                datatype: "json",
                colNames: ['操作','单位编号', '单位','排序','添加时间','创建人'],
                colModel: [
                            {name:'act',index:'act',width:30,search:false,sortable:false},
                            {name: 'UID', index: 'UID', width: 50,search:true},
                            {name: 'UName', index: 'UName', width: 50,
                            search:true,
                            searchoptions:{sopt:['eq']},
                            stype:'text',
                            editable:true,
							edittype:'text',
							editoptions:{size:10,maxlength:15},
							editrules:{required:true},
							formoptions:{elmprefix:'(*)'}},
                            {name: 'Sort', index: 'Sort', width: 50,search:false,
                            editable:true,
							edittype:'text',
							editoptions:{size:10,maxlength:15},
							editrules:{required:true},
							formoptions:{elmprefix:'(*)'}},
                            {name: 'AddTime', index: 'AddTime', width: 50,search:false}, 
                            {name: 'Creator', index: 'Creator', width: 50,search:false},                        
                           ],//这里是数据读取到的字段列名
            
			//loadtext: "Loading...",
            rowNum: 3,
            //rowList: [10, 20, 30],
            sortorder:"desc",
            sortname:"UID",
            pager: '#pager',
            //pginput:false,
            //pgbuttons:false,
            viewrecords: true,
            recordtext: "当前显示：{0}-{1}条 共：{2}条",
			emptyrecords: "没有记录",
			//pgtext : "Page {0} of {1}",
			pgtext : '当前页：{0} 共：{1}页',
            multiselect: true,        
            height:ph,
            autowidth:true,
            gridComplete: function(){
                var ids = $("#list").getDataIDs();//jqGrid('getDataIDs');
                for(var i=0;i<ids.length;i++){
                    var cl = ids[i];
                    be = "<input style='height:22px;width:40px;' type='button' value='编辑' onclick=\"jQuery('#list').jqGrid('editGridRow','"+cl+"',{checkOnSubmit:true,checkOnUpdate:true,closeAfterEdit:true,closeOnEscape:true});\"  />"; 
                    //be = "<input class='inputbtn' type='button' value='编辑' onclick=\"$.fn.popup({iframe:true,url:'Product/ProductAdd_Step2.aspx?from=list&cid=88&ProductID=492&group=492',title:'修改商品',type:9,width:$(window).width(),height:$(window).height()});\"  />"; 
                    de = "<input style='height:22px;width:40px;' type='button' value='删除' onclick=\"jQuery('#list').jqGrid('delGridRow','"+cl+"',{closeOnEscape:true});\"  />";
                    //de="";
                    jQuery("#list").jqGrid('setRowData',ids[i],{act:be+de});
                };
                /*
                ShowPageBar("pageDataList1_Pager",
							"Unit.aspx",//[url]
							{style:"flickr",mark:"pageDataList1Mark",
							totalCount:$("#list").getGridParam("records"),showPageNumber:3,pageCount:$("#list").getGridParam("rowNum"),currentPageIndex:1,noRecordTip:" 没有记录",preWord:"上一页",nextWord:"下一页",
							onclick:"CurrentPage={pageindex};BindProducts('Unit.aspx');return false;"}//[attr]
				);
                $("#record").html("共"+$("#list").getGridParam("records")+"条"); 
                */
            },
            editurl:'Unit.aspx',
            jsonReader:{
                repeatitems : false
            }
            })
            //.navGrid("#pager", { edit: true, add: true, del: true },{multipleSearch:true})
            //.jqGrid('navButtonAdd','#pager',{caption:'<div class="inputbtn">上一页</div>',title:'上一页',onClickButton:function(){alert('上一页')},position:'last'});
            //多字段查询
            $("#list").jqGrid('navGrid','#pager',{add:true,addtext:'添加',edit:true,edittext:'编辑',editfunc:editFn,del:true,deltext:'删除',refresh: true,refreshtext:'刷新',search:true,searchtext: '查询'},{},{},{},{multipleSearch:true});
            /*
            //单字段查询
            $("#list").jqGrid('navGrid','#pager',{edit:true,add:true,del:true,search:true},{},{},{},{multipleSearch:false});	
            */			
            
            $("#btnAdd").click(function(){
				//pop({text:'恭喜你,注册成功!'},1,function(){});
				$.fn.popup({iframe:true,url:'unit1.aspx',title:'百度',type:9,width:$(window).width(),height:$(window).height()});
            });
            /*
            $("#btnAdd").click(function(){
				 $("#list").jqGrid('editGridRow','new',{height:150,reloadAfterSubmit:true,closeOnEscape:true,addedrow:'first'});
            });
            */
            $("#btnDelete").click(function(){
				alert($("#list").getGridParam("selarrrow"));
            }); 
            $("#btnSearch").click(function(){
				$("#list").jqGrid('searchGrid',
					{sopt:['cn','bw','eq','ne','lt','gt','ew']}
				);
            });  
            $("#btnRefresh").click(function(){
				//$("#list").trigger("reloadGrid");
            }); 
             
     });
     var editFn = function(rowid){
		alert(rowid);
	 };
    </script>
	</HEAD>
	<body>	    
    <div class="container">
		<div class="sub_container">
		    <div class="sub_container_title"><a href="<%=AdminDefault%>" target="_top">桌面</a><img src="images/admin_title.jpg" height=9px width=8px align="absmiddle" />
		       单位列表
		    </div>
		    <div id="operation" class="sub_container_operation">
				<ul>
					<li><input type="button" id="btnAdd" value="添加" class="inputbtn" /></li>
					<li><input type="button" id="btnSearch" value="搜索" class="inputbtn" /></li>
				    <li><input type="button" id="btnDelete" value="删除" class="inputbtn" /></li>
				    <li><input type="button" id="btnRefresh" value="刷新" class="inputbtn" /></li>
				</ul>
		    </div>
		    <div class="clear"></div>
		    <div class="sub_container_content" style="padding:0px;">
		        <table id="list" class="scroll" cellpadding="0" cellspacing="0"></table>
		        <!--
		        <div id="pageDataList1_Pager" class="sub_container_page">
					
					<div class="flickr" id="pageDataList1_Pager_pageBar">
						<span class="disabled">上一页</span>
						<span class="current">1</span>
						<a href="">2</a>
						<a onclick="CurrentPage=2;BindProducts('Product.aspx');return false;" href="#pageDataList1Mark">下一页</a>
						<span id="record"></span>
						<span id="pages"></span>
					</div>
					
				</div>
				-->
                <div id="pager" class="scroll" style="text-align: center;"></div>
		    </div>
		</div>
	</div>
	</body>
</HTML>