// JavaScript Document 
var captionname = "";
$(function() {
	var id = 0;
	$("#list2").jqGrid( {
		url : APP + '/Home/NewsList/getNewsLists/ncid/' + ncid,
		datatype : "json",
		colNames : [ '', ' ', '标题', '时间' ],
		colModel : [ {
			name : 'ordid',
			index : 'ordid',
			align : 'right',
			resizable : false,
			fixed : true,
			width : 45
		}, {
			name : 'news_id',
			index : 'news_id',
			align : 'left',
			resizable : false,
			fixed : true,
			hidedlg : true,
			hidden : true
		}, {
			name : 'ntitle',
			index : 'ntitle',
			align : 'left',
			resizable : false,
			fixed : true,
			width : 400
		}, {
			name : 'nidate',
			index : 'nidate',
			align : 'right',
			fixed : true,
			width : 282
		} ],
		rowNum : 10,
		rowTotal : 2000,
		rowList : [ 10, 20, 30 ],
		pager : '#pager2',
		sortname : 'news_id',
		viewrecords : true,
		sortorder : "desc",
		height:'100%',
		caption : captionname,
		loadonce : true,
		loadError : function(data, status, error) {
			alert("loadError" + status);
		},
		loadComplete : function(data) {
			// alert(data.toSource());
		captionname = data.caption_for_sort;
		$(this).jqGrid('setCaption', captionname);
	},
	onCellSelect : function(id) {
		var row = $("#list2").getRowData(id); // 根据ID拿到一行的数据
		var url = APP + '/Home/NewsDetails/index/nid/' + row.news_id;
		 // alert(url);
	  window.location =url;
	},
	prmNames : {
		page : "page", // 表示请求页码的参数名称
		rows : "rows", // 表示请求行数的参数名称
		sort : "sidx", // 表示用于排序的列名的参数名称
		order : "sord", // 表示采用的排序方式的参数名称
		search : "search", // 表示是否是搜索请求的参数名称
		nd : "nd", // 表示已经发送请求的次数的参数名称
		id : "id", // 表示当在编辑数据模块中发送数据时，使用的id的名称
		oper : "oper", // operation参数名称（我暂时还没用到）
		editoper : "edit", // 当在edit模式中提交数据时，操作的名称
		addoper : "add", // 当在add模式中提交数据时，操作的名称
		deloper : "del", // 当在delete模式中提交数据时，操作的名称
		subgridid : "id", // 当点击以载入数据到子表时，传递的数据名称
		npage : null,
		totalrows : "totalrows" // 表示需从Server得到总共多少行数据的参数名称，参见jqGrid选项中的rowTotal
	},
	jsonReader : {
		root : "rows", // json中代表实际模型数据的入口
		page : "page", // json中代表当前页码的数据
		total : "total", // json中代表页码总数的数据
		records : "records", // json中代表数据行总数的数据
		repeatitems : true, // 如果设为false，则jqGrid在解析json时，会根据name来搜索对应的数据元素（即可以json中元素可以不按顺序）；而所使用的name是来自于colModel中的name设定。
		cell : "cell",
		id : "id",
		userdata : "userdata",
		subgrid : {
			root : "rows",
			repeatitems : true,
			cell : "cell"
		}
	}
	});
	//alert(captionname);
	// var rowNum = jQuery("#list2").getGridParam("sort1");

	// alert( jQuery("#list2").jqGrid('getGridParam','userData' ).toSource());
	// alert( jQuery("#list2").jqGrid('getDataIDs') );
	// alert($("#list2").jqGrid('getGridParam','caption'));
	// alert($("#list2").jqGrid('getGridParam','jsonReader','caption').toSource()
	// );
	// alert($("#list2").jqGrid('getGridParam','caption'));
	// $("#list2").jqGrid('setCaption',$("#list2").jqGrid('getGridParam',
	// 'jsonReader').sort1);

	// var id = jQuery("#list2").jqGrid('getGridParam','selrow');
	// alert(id);

	// $("#list2").jqGrid('navGrid','#pager2',{edit:false,add:false,del:false});
});
// $("#list2").jqGrid('getGridParam','caption')='12';

