데이터grid 동적 로드 열column

2969 단어 datagrid

 
/**
	 *  
	 */
	$(document).ready(function() {
		loadDatagrid();
	});

	/**
	 *  
	 */
	function loadDatagrid() {
		//debugger;
		var columns = new Array();

		var dataGridColumnValStr = $.trim($("#DataGridColumnVal").text());
		var dataGridColumnFieldStr = $.trim($("#DataGridColumnField").text());

		if (dataGridColumnValStr != null && dataGridColumnValStr != "" && dataGridColumnValStr != "null"
				&& typeof (dataGridColumnValStr) != "undefined") {

			var colValArray = dataGridColumnValStr.split(",");
			var colFieldArray = dataGridColumnFieldStr.split(",");

		for (var i = 0; i < colValArray.length; i++) {
				var column = {};
				column["field"] = colFieldArray[i];
				column["title"] = colValArray[i];
				column["sortable"] = true;
				column["halign"] = "center";
				column["align"] = "right";

				columns.push(column);
			}
		}

		$('#dg_sub').datagrid({
			singleSelect : true,
			pagination : true,

			loadMsg : "",
			url : ctx + "/acc/balance_sheet/ajax_balance_sheet_query",
			queryParams : {

			},
			columns : [
				columns
			],
			onClickRow : function(rowIndex, rowData) {
				if (rowData.vCreate_by == 0) {
					$("#history").attr("onclick", "returnTo('history')");
					$("#history").css("background-color", "");
				} else {
					$("#history").attr("onclick", "");
					$("#history").css("background-color", "gray");
				}
				$("#au_desc").val(rowData.au_desc);
				$("#description").val(rowData.description);
				$("#create_date").val(new Date(rowData.create_date).format("yyyy-MM-dd"));
				$("#create_by").val(rowData.create_by);
				$("#group_description").val(rowData.group_description);
				$("#approve_by").val(rowData.approve_by);
				$("#post_by").val(rowData.post_by);
			},
			onLoadError : function() {
				grid_layer_close();
				$('#dg_sub').datagrid('options').loadMsg = loadingMsg;
			},
			onLoadSuccess : function(data) {
				grid_layer_close();
				$('#dg_sub').datagrid('options').loadMsg = loadingMsg;

				$('#dg_sub').datagrid('selectRecord', '${voucherLineId}');

			}
		});
	}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

좋은 웹페이지 즐겨찾기