/*以下、表一覧画面の表示オブジェクト*/
var _ =function(){
	var constructorF = function(){
		var _this = this;

		//各種定義
		//ソートの選択肢として利用する、整形済み列名配列
		var aryFormedColName =[];
		//レスポンスのデータにアクセスする際に、表示列毎に何列目のレスポンスを読むか、と言う一覧。
		var aryDataIdx = [];
		//レスポンスのデータを表示する際に利用する、型情報。
		var aryDataType = [];
		//ソート関数配列。ソート方法指定のvalueはこれのインデックス
		var arySortFuncs =[];

		//各種システム表
		var uqTbl;
		var tblTbl;
		var colTbl;
		var optTbl;

		var typeTbl;
		var modeTbl;
		var typeModeTbl;



		//ソート時は、レスポンスデータに対して、これで指定された列を順次比較する。
		var aryDataIdx4srt = [];

		//スクロールさせる為に分割したテーブルエレメント各種
		var elmTblTopLeft;
		var elmTblTopRight;
		var elmTblBodyLeft;
		var elmTblBodyRight;

		//ソート対象の指定
		var sortSelected ={
			col : -1,
			odr : -1
		};

		//検索時の列指定用配列
		var aryColInfo4Search;

		var mainInner;
		var searchSubWrap;
		var blkSubWrap;



		//検索し、結合した表情報を取得する。
		var loadTblJ = function(){
			_tableData._loadJoin( disp );
		};
		var loadTbl = function(){
			_tableData._loadSingle( loadTblJ , {
				db_id : _this.dbId,
				table_id : _this.tblId
			} );
		};
		var mode;
		var init = function( objSwitch ){
			//objSwitchが指定されている場合は、直前の検索条件を引き継ぐ。
			if( ! objSwitch ){
				var req = {
					db_id : _this.dbId,
					table_id : _this.tblId
				};
				_tableData._req = req;
				//ソート条件も併せて初期化
				//ちなみに、他セッションからソートの設定が変更された場合、orderがずれるので注意すること。
				sortSelected ={
					col : -1,
					odr : -1
				}; 
				mode = "lv";
			}else if( objSwitch.mode ){
				mode = objSwitch.mode;
			}else{
				mode = "lv";
			};

			_sysData._loadChain([
				"tbl",
				"col",
				"uq",
				"rlt",
				"sort",
				"opt"
			] , { db_id : _this.dbId } , loadTbl );

		};
		this.init = init;
		var formatStr = {
			4:"YYYY/MM/DD HH:MI:SS",
			5:"YYYY/MM/DD",
			6:"HH:MI:SS"
		};

		var validate = function( tr , ary ){
			var colValue = _D.fEC( _D.fEC( tr ) ).value;
			if( ! _U.isIdx( colValue , aryColInfo4Search ) ){
				return true;
			};
			var colInfo = aryColInfo4Search[ colValue ];
			var type = colInfo.type;

			if( _U.find( type , [ 4 , 5 , 6 ] ) == -1 ){
				return true;
			};
			var ret = true;
			for( var i = 0 ; ret && _U.isIdx( i , ary ) ; i ++ ){
				if( ary[ i ] != "" ){
					ret = _tableData.dataValidation( ary[ i ] , type );
				};
			};
			if( ! ret ){
				var msg = _msg.getMessage( "cmmn_W0" );
				var mainMsgObj =  msg.main ;
				mainMsgObj.discription = msg.sub.t;
				mainMsgObj.discription = mainMsgObj.discription.replace( new RegExp( "#0#" , "g") , colValue.colName )
				mainMsgObj.discription = mainMsgObj.discription.replace( new RegExp( "#1#" , "g") , ary[ i ] )
				mainMsgObj.discription = mainMsgObj.discription.replace( new RegExp( "#2#" , "g") , formatStr[ type ] )

				_disp.showMessage( mainMsgObj );
				return false;
			};

			return ret;
		};
		var getCriteria = function( tr ){
			var colValue = _D.fEC( _D.fEC( tr ) ).value;
			var slctMode = _D.fEC( tr.children[ 2 ] );
			var chkNot = _D.fEC( tr.children[ 1 ] );

			if( ! _U.isIdx( colValue , aryColInfo4Search ) || slctMode.value == -1 ){
				return null;
			};

			var colInfo = aryColInfo4Search[ colValue ];
			var ret ={
				col_table	:	colInfo.table	,
				col_relats	:	colInfo.relats	,
				column_id	:	colInfo.col	,
				Not		:	chkNot.checked	,
				Mode		:	slctMode.value	,
				Criteria	:	[]
			};
			if( slctMode.value == 7 ){
				return ret;
			};

			var criteriaIdx = getElmIdxByMode( slctMode.value );
			//criteriaElmは、モードがレンジの場合、fieldsetである点に注意する。
			var criteriaElm = tr.children[ 3 ].children[ criteriaIdx ];

			var wkAry =[];

			if( slctMode.value == 3 ){
				wkAry.push( _D.fEC ( _D.fEC ( criteriaElm ) ).value );
				wkAry.push( _D.fEC ( _D.lEC ( criteriaElm ) ).value );
			}else if( criteriaIdx == 0 ){
				var str = criteriaElm.value;
				var ary =[];
				if( str.indexOf( "|" ) != -1 ){
					var ary = str.split("|");
					ary.forEach( function( str ){
						wkAry.push( str.trim() );
					});
				}else{
					wkAry.push( str );
				};
			}else{
				wkAry.push( criteriaElm.value );
			};

			var allNull = true;
			for( var i = 0 ; _U.isIdx( i , wkAry ) ; i ++ ){
				if( wkAry[i] != "" ){
					allNull = false;
				};
				var val = wkAry[i];
				if( _U.find( colInfo.type , [4,5,6] ) != -1 ){
					val = _tableData._dataConv4ReqStr( wkAry[i] , colInfo.type );
				};
				ret.Criteria.push( val );
			};
			return ret;

		};
		var setCriteria = function( tr , searchInfo ){

			var colInfo = _sysData._tblFind( aryColInfo4Search ,[
				{ key:"table" , value:searchInfo.col_table },
				{ key:"relats" , value:searchInfo.col_relats },
				{ key:"col" , value:searchInfo.column_id }
			] , true )[0];

			if( ! colInfo ){
				return false;
			};
			var slctCol = _D.fEC( _D.fEC( tr ) );
			slctCol.value = _U.find( colInfo , aryColInfo4Search );
			slctCol.onchange();

			var slctMode = _D.fEC( tr.children[ 2 ] );
			slctMode.value = searchInfo.Mode;
			slctMode.onchange();

			var chkNot = _D.fEC( tr.children[ 1 ] );
			chkNot.checked = searchInfo.Not;

			//isNullの場合は条件なし
			if( slctMode.value == 7 ){
				return true;
			};

			var criteriaIdx = getElmIdxByMode( slctMode.value );
			//criteriaElmは、モードがレンジの場合、fieldsetである点に注意する。
			var criteriaElm = tr.children[ 3 ].children[ criteriaIdx ];

			var aryC = searchInfo.Criteria;
			if( _U.find( colInfo.type , [4,5,6] ) ){
				aryC.forEach( function( a ){
					a = _tableData._dataConv4HtmlStr( a , colInfo.type );
				});
			};

			if( slctMode.value == 3 ){
				_D.fEC ( _D.fEC ( criteriaElm ) ).value = aryC[ 0 ];
				_D.fEC ( _D.lEC ( criteriaElm ) ).value = aryC[ 1 ] ;
			}if( criteriaIdx == 0 ){
				criteriaElm.value = aryC.join( " | " );
			}else{
				criteriaElm.value = aryC[ 0 ];
			};
			return true;
		};
		var getElmIdxByMode = function( mode ){
			ret = -1;
			if( _U.find( mode , [ 1 , 2 , 6 ] ) != -1 ){
				ret = 0;
			}else if( mode == 3 ){
				ret = 3;
			}else if( mode == 4 ){
				ret = 1;
			}else if( mode == 5 ){
				ret = 2;
			};
			return ret;
		};
		var changeSearchCriteria = function( tr , col , mode ){
			var targTd = tr.children[ 3 ];
			var idx = getElmIdxByMode( mode );
			if( mode == 4 ){

				//セレクトモードの場合は、セレクト部品にオプションを設定する。
				var slct = targTd.children[ idx ];
				slct.innerHTML = "";
				_D.aCAndCN( slct , {attr:{tagname:"option",value:"",selected:true}} );

				var opts = _sysData._tblFind( optTbl , [{key:"colId",value:col.col }] );
				
				for( var i = 0 ; _U.isIdx( i , opts ) ; i++ ){
					_D.aCAndCN( slct , {attr:{
						tagname:"option",
						value: opts[i].value,
						label: opts[i].value
					}} );
				};
			};
			for( var i = 0 ; _U.isIdx( i , targTd.children ) ; i ++ ){
				_D.show( targTd.children[i] , i == idx );
			};
			if( idx == 0 ){
				targTd.children[idx].onchange();
			}else if( idx == 3 ){
				_D.fEC( _D.fEC( targTd.children[idx] ) ).onchange();
				_D.lEC( _D.lEC( targTd.children[idx] ) ).onchange();
			};


		};
		var changeSearchMode = function( tr , type ){
			var targs = _sysData._tblFind( typeModeTbl ,[{ key:"type_id" , value:type }] );
			var slctMode = _D.fEC( tr.children[ 2 ] );
			for( var i = 0 ; _U.isIdx( i , slctMode.children ) ; i ++ ){
				if( _sysData._tblFind( targs ,[{ key:"mode_id" , value:slctMode.children[i].value }] , true )[0] ){
					_D.show( slctMode.children[ i ] , true );
				}else{
					_D.show( slctMode.children[ i ] , false );
					if( slctMode.children[ i ].selected ){
						slctMode.value =-1;
					};
				};
			};

			if( slctMode.value == -1 && type != -1 ){
				if( type == 7 ){
					slctMode.value = 5;
				}else if( type == 8 ){
					slctMode.value = 4;
				}else{
					slctMode.value = 1;
				};
			};


			return slctMode.value;
		};
		var appendSeachInfo = function(){
			//リクエスト情報を取得し、検索条件を画面に反映させる。
			var tbody = _D.g("lstvw_tbody_search");
			tbody.innerHTML = "";

			var SearchedReq = _tableData._getReq();
			var btnSearchAdd = _D.g("lstvw_btn_search_add");
			if( SearchedReq.Criteria && SearchedReq.Criteria.constructor == Array && SearchedReq.Criteria.length > 0 ){
			//検索条件があるならば･･･
				for( var i = 0 ; _U.isIdx( i , SearchedReq.Criteria ) ; i++ ){
					var srchData = SearchedReq.Criteria[i];
					var tr = btnSearchAdd.onclick();
					setCriteria( tr , srchData );
				};
			}else{
				//検索条件が無いならば･･･
				btnSearchAdd.onclick();
			};
		};

		var searchWork = function(){
			var tbody = _D.g("lstvw_tbody_search");
			var aryC = [];
			for( var i = 0 ; _U.isIdx( i , tbody.children ) ; i++ ){
				var c = getCriteria( tbody.children[i] );
				if( c ){
					aryC.push(c);
				};
			};
			var req = {
				db_id : _this.dbId,
				table_id : _this.tblId,
				Criteria :aryC
			};
			_tableData._setReq( req );
			init( { mode : "lv"});
		};
		var focusCancel = function(){
			var targ = document.activeElement;
			if( targ && _D.par( targ ) != _D.g("btn_area") ){
				targ.blur();
			};
		};

		var blkWorkMode ={
			"cp":"cp",
			"dl":"dl",
			"ud":"ud"
		};

		var blkCheck = function(){
			var aryChk = _D.gN("lstvw_chk_each");
			for( var i = 0 ; _U.isIdx( i , aryChk ) ; i++ ){
				if( aryChk[ i ].checked ){
					return true;
				};
			};
			_disp.showMessageEz( "lv_blk_W0" );

			return false;
		};

		var blBlkWorkIsUpdate ;
		var blkWorks = function( mode , objUpdateInfo ){
			if( ! blkWorkMode[mode] ){
				return;
			};
			var aryRowId = [];
			var aryChk = _D.gN("lstvw_chk_each");
			for( var i = 0 ; _U.isIdx( i , aryChk ) ; i++ ){
				if( aryChk[ i ].checked ){
					aryRowId.push( aryChk[ i ].dataset.rowid )
				};
			};
			var req = {
				db_id : _this.dbId,
				table_id : _this.tblId,
			};
			for( var i = 0 ; _U.isIdx( i , aryRowId ) ; i++ ){
				req[ "row_id[" + i + "]" ] = aryRowId[ i ];
			};
			//urlを取得、udの場合は第2引数からそのままキー、値を転記する。
			var url;
			var msgCd = "";
			blBlkWorkIsUpdate = false;
			if( mode == blkWorkMode.cp ){
				url = _urlMap.action.blkCpy;
				msgCd = "lv_blk_0";
			}else if( mode == blkWorkMode.dl ){
				url = _urlMap.action.blkDel;
				msgCd = "lv_blk_1";
			}else if( mode == blkWorkMode.ud ){
				url = _urlMap.action.blkUpd;
				for( var key in objUpdateInfo ){
					req[ key ] = objUpdateInfo[ key ];
				};
				msgCd = "sub_bk_1";
				blBlkWorkIsUpdate = true;
			};
			_disp.showMessageEz( msgCd , [] , function(){
				_disp.request( "php/" + url , req , blkFinMsg );
			} );
		};
		var blkFinMsg = function( obj ){
			var str = "The number of changed rows : " + obj.rows;
			_disp.showMessageEz( "cmmn_10" , [str] , function(){
				//更新の場合のエラー時は何もしない。
				if( obj.mode == "W" && blBlkWorkIsUpdate ){
					return;
				};
				//更新以外の場合は再読み込みを行う。
				init({mode:"blk"});
			} );
		};

		var openDtView = function( e ){
			
			for( var target = e.target || e.srcElement; target != null && target.tagName != "TR" && target.tagName != "TBODY"  ; target =_D.par(target) );
			if( target == null || target.tagName == "TBODY"){
				return;
			};

			var rowId = target.dataset.rowid;
			var tbody = _D.par( target );
			var index = 0;
			for( var i = 0 ; _U.isIdx( i , tbody.children ) ; i ++ ){
				if( tbody.children[i] == target ){
					var index = i;
					break;
				};
			};
			_disp.dipsCtrl( _disp.id.DtV , {
				mode:"vw",
				rowid:rowId,
				index:index
			} );
		};

		var _TIMER_ID_ = null;
		var _PREV_SC_Y_ = null;
		var _PREV_SC_X_ = null;
		var eventFuncs ={
			tableWrapOnScroll : function(){
				var scL = this.scrollLeft;
				var scT = this.scrollTop;
				var blX = false;
				var blY = false;
				if( scL != _PREV_SC_X_ ){
					blX = true;
					_PREV_SC_X_ = scL;
				};
				if( scT != _PREV_SC_Y_ ){
					blY = true;
					_PREV_SC_Y_ = scT;
				};
				if( blX ){
					elmTblTopLeft.style.left = "0px";
					elmTblBodyLeft.style.left = "0px";

				};
				if( blY ){
					elmTblTopLeft.style.top = "0px";
					elmTblTopRight.style.top = "0px";
				};

				if( _TIMER_ID_ ){
					clearTimeout(_TIMER_ID_);
				};
				var _WRAP_ = this; 
				_TIMER_ID_ = setTimeout( function(){
					elmTblTopLeft.style.left = scL + "px";
					elmTblBodyLeft.style.left = scL + "px";
					elmTblTopLeft.style.top = scT + "px";
					elmTblTopRight.style.top = scT + "px";
				},1000);
			},
			selectSortColOnChange:function(){
				sortSelected.col = this.value;
				sortAndMoveTr();
			},
			selectSortOrderOnChange:function(){
				sortSelected.odr = this.value;
				sortAndMoveTr();
			},
			btnBlkModeOnClick:function(){
				init( { mode : "blk"});
			},
			btnLvModeOnClick:function(){
				init( { mode : "lv"});
			},
			btnAllOnClick:function(){
				var aryChk = _D.gN("lstvw_chk_each");
				var haveToCheck = false;
				for( var i = 0 ; _U.isIdx( i , aryChk ) ; i++ ){
					if( ! aryChk[ i ].checked ){
						haveToCheck = true;
						break;
					};
					aryChk[ i ].checked = false;
				};
				if( ! haveToCheck )return;
				for( var i = 0 ; _U.isIdx( i , aryChk ) ; i++ ){
					aryChk[ i ].checked = true;
				};
			},
			btnSearchOnClick:function(){
				_D.show( searchSubWrap , true );
				appendSeachInfo();
				if( document.activeElement ){
					document.activeElement.blur(); 
				};
				mainInner.addEventListener("focus", focusCancel, true);
			},
			btnCancelOnClick:function(){
				_D.show( searchSubWrap , false );
				mainInner.removeEventListener("focus", focusCancel, true);
			},
			btnSearchAddOnClick:function(){
				var tbody = _D.g("lstvw_tbody_search");
				var tr = _D.aCAndCN( tbody , nodeDef.trSearchBody );
				return tr;
			},
			btnSearchDelOnClick:function(){
				var tr = _D.par(_D.par( this ));
				_disp.showMessageEz( "sub_sc_0" , null , function(){ 
					_D.rC(tr);
				});
			},
			slctSearchColOnChange:function(){
				var tr = _D.par( _D.par( this ) );
				var type;
				if( this.value == -1 ){
					type = -1;
				}else{
					type = aryColInfo4Search[ this.value ].type;
				}

				var mode = changeSearchMode( tr , type );
				changeSearchCriteria( tr , aryColInfo4Search[ this.value ] , mode );
			},
			slctSearchModeOnChange:function(){
				var tr = _D.par( _D.par( this ) );
				var colValue = _D.fEC( _D.fEC( tr ) ).value;
				var type;
				if( colValue == -1 ){
					type = -1;
				}else{
					type = aryColInfo4Search[ colValue ].type;
				}
				changeSearchCriteria( tr , aryColInfo4Search[ colValue ] , this.value );
			},
			txtValidate:function(){
				var str = this.value;
				var ary =[];
				if( str.indexOf( "|" ) != -1 ){
					var wkAry = str.split("|");
					wkAry.forEach( function( str ){
						ary.push( str.trim() );
					});
				}else{
					ary.push( str );
				};
				var bl = validate( _D.par(_D.par( this ) ) , ary );
				if( bl ){
					this.style.backgroundColor = "#FFFFFF";
				}else{
					this.style.backgroundColor = "#FFFF00";
				};
			},
			txtValidateRange:function(){
				var str = this.value;
				var ary =[ str ];
				var bl = validate( _D.par(_D.par(_D.par(_D.par( this ) ) ) ) , ary );
				if( bl ){
					this.style.backgroundColor = "#FFFFFF";
				}else{
					this.style.backgroundColor = "#FFFF00";
				};
			},
			btnSearchWorkOnClick:function(){
				searchWork();
			},
			btnBlkCpOnClick:function(){
				if( ! blkCheck() ) return;
				blkWorks( blkWorkMode.cp );
			},
			btnBlkUdOnClick:function(){
				if( ! blkCheck() ) return;
				_D.g("lstvw_tbody_blkud").innerHTML ="";
				_D.g("lstvw_btn_blkud_add").onclick();
				_D.show( blkSubWrap , true );
				if( document.activeElement ){
					document.activeElement.blur(); 
				};

				mainInner.addEventListener("focus", focusCancel, true);
			},
			btnBlkudCancelOnClick:function(){
				_D.show( blkSubWrap , false );
				mainInner.removeEventListener("focus", focusCancel, true);
			},

			btnBlkDlOnClick:function(){
				if( ! blkCheck() ) return;
				blkWorks( blkWorkMode.dl );
			},
			btnBlkudWorkOnClick:function(){
				//更新条件を取得する処理を後で追加すること。
				var tbody = _D.g("lstvw_tbody_blkud");
				var aryColValue = [];
				var req = {};

				for( var i = 0 ; _U.isIdx( i , tbody.children ) ; i++ ){
					var tr = tbody.children[ i ];
					var slctCol = _D.fEC( _D.fEC( tr ) );
					if( slctCol.value == "" )continue;
					var inputElm = _D.fEC( tr.children[1] );
					var colValue = inputElm.getMyValue();
					aryColValue.push( {
						col:slctCol.value,
						value:colValue
					} );
				};
				if( aryColValue.length == 0 ){
					_disp.showMessageEz( "lv_blk_W0" );
					return;
				};


				for( var i = 0 ; _U.isIdx( i , aryColValue ) ; i ++ ){
					req[ "col["+i+"]" ] = aryColValue[i].col;
					req[ "value["+i+"]" ] = aryColValue[i].value;
				};
				blkWorks( blkWorkMode.ud , req );
			},
			btnBlkudAddOnClick:function(){
				var tbody = _D.g("lstvw_tbody_blkud");
				var tr = _D.aCAndCN( tbody , nodeDef.trBlkBody );
				return tr;
			},
			slctBlkUdColOnChange:function(){
				var tr = _D.par( _D.par( this ) );
				var targTd = tr.children[ 1 ];
				targTd.innerHTML = "";
				if( this.value == "" ){
					return;
				};
				var dispElms = _cmnParts.getParts( this.value );
				if( ! dispElms )return;
				_D.aC( targTd , dispElms.inputElm );
				for( var i= 0 ; _U.isIdx( i , dispElms.relatsSubTables ); i++ ){
					_D.aC( targTd , dispElms.relatsSubTables[i] );
				};
			},
			slctBlkUdColOnFocus:function(){
				var myTr = _D.par( _D.par( this ) );
				var tbody = _D.par( myTr );
				var aryColSelectedValue = [];
				for( var i = 0 ; _U.isIdx( i , tbody.children ) ; i ++ ){
					var tr = tbody.children[ i ];
					if( tr == myTr ) continue;
					var slctCol = _D.fEC( _D.fEC( tr ) );
					if( slctCol.value != "" ){
						aryColSelectedValue.push( slctCol.value );
					};
				};
				for( var i = 0 ; _U.isIdx( i , this.children ) ; i ++ ){
					var opt = this.children[ i ];
					if( _U.find( opt.value , aryColSelectedValue ) != -1 ){
						_D.show( opt , false );
					}else{
						_D.show( opt , true );
					};
				};
			},
			btnBlkDelOnClick:function(){
				var tr = _D.par( _D.par( this ) );
				var slctCol = _D.fEC( _D.fEC( tr ) );
				var str = slctCol.options[ slctCol.selectedIndex ].label;
				if( slctCol.value != "" ){
					_disp.showMessageEz( "sub_bk_0" , [str] , function(){ _D.rC( tr ); } );
				}else{
					_D.rC( tr );
				};
			},
			btnAddRcdOnClick:function(){
				_disp.dipsCtrl( _disp.id.DtV , {
					mode:"add"
				} );
			}
		};


		var nodeDef ={
			mainInner :{attr:{
				tagname:"div",
				className:"_vh_sc_hddn_ _lstvw_"
			},children:[
				{attr:{
					tagname:"h1",
					className:"_titles_ _lstvw_h1_"
				},children:[
					{attr:{
						tagname:"div",
						id:"lstvw_div_table_name"
					},children:[
						{attr:{
							tagname:"span",
							innerHTML :"List View - ",
							className:"_lstvw_mode_lv_"
						}},
						{attr:{
							tagname:"span",
							innerHTML :"Bulk Operation - ",
							className:"_lstvw_mode_blk_"
						}},
						{attr:{
							tagname:"span",
							id:"lstvw_span_table_name",
							innerHTML :""
						}}
					]},



					{attr:{
						tagname:"input",
						type :"button",
						id:"lstvw_btn_mode_blk",
						value:"Bulk Operation mode",
						onclick : eventFuncs.btnBlkModeOnClick,
						className:"_btn_w_ _btn_in_title_ _lstvw_mode_lv_"
					}},
					{attr:{
						tagname:"input",
						type :"button",
						id:"lstvw_btn_mode_lv",
						value:"List View mode",
						onclick : eventFuncs.btnLvModeOnClick,
						className:"_btn_w_ _btn_in_title_ _lstvw_mode_blk_"
					}},
					{attr:{
						tagname:"span",
						className:"_lstvw_span_btn_wrap_"
					},children:[
						{attr:{
							tagname:"input",
							type :"button",
							id:"lstvw_btn_add",
							value:"add Record",
							onclick : eventFuncs.btnAddRcdOnClick,
							className:"_btn_in_title_"
						}},
						{attr:{
							tagname:"input",
							type :"button",
							id:"lstvw_btn_search",
							value:"search",
							onclick: eventFuncs.btnSearchOnClick,
							className:"_btn_in_title_"
						}}
					]}
					
				]},
				{attr:{
					tagname:"div",
					className:"_lstvw_div_top_area_"
				},children:[
					{attr:{
						tagname:"div",
						id:"lstvw_div_row_count"
					},children:[
						{attr:{
							tagname:"span",
							innerHTML:"",
							id:"lstvw_span_row_count"
						}},
						{attr:{
							tagname:"span",
							innerHTML:"records"
						}}
					]},

					{attr:{
						tagname:"span",
						className:"_lstvw_span_top_area_wrap_ _lstvw_mode_lv_"
					},children:[
						{attr:{
							tagname:"label",
							innerHTML:"sort column :",
							className:"_lstvw_lbl_top_area_"
						},children:[
							{attr:{
								tagname:"select",
								onchange: eventFuncs.selectSortColOnChange,
								id:"lstvw_slct_srt_col"
							}}
						]},
						{attr:{
							tagname:"label",
							innerHTML:"sort order :",
							className:"_lstvw_lbl_top_area_"
						},children:[
							{attr:{
								tagname:"select",
								onchange: eventFuncs.selectSortOrderOnChange,
								id:"lstvw_slct_srt_odr"
							}}
						]}
					]},
					{attr:{
						tagname:"span",
						className:"_lstvw_span_top_area_wrap_ _lstvw_mode_blk_"
					},children:[
						{attr:{
							tagname:"input",
							type :"button",
							id:"lstvw_btn_copy",
							value:"copy",
							onclick: eventFuncs.btnBlkCpOnClick,
							className:"_btn_y_"
						}},
						{attr:{
							tagname:"input",
							type :"button",
							id:"lstvw_btn_upd",
							value:"update",
							onclick: eventFuncs.btnBlkUdOnClick,
							className:"_btn_y_"
						}},
						{attr:{
							tagname:"input",
							type :"button",
							id:"lstvw_btn_del",
							value:"delete",
							onclick: eventFuncs.btnBlkDlOnClick,
							className:"_btn_y_"

						}}
					]}

					
				]},
				{attr:{
					tagname:"div",
					className:"_lstvw_table_area_"
				},children:[
					{attr:{
						tagname:"div",
						id:"lstvw_div_table_scroll",
						className:"_vh_sc_auto_ _lstvw_table_area_inner_",
						onscroll: eventFuncs.tableWrapOnScroll
					},children:[
						{attr:{
							tagname:"table",
							id:"lstvw_tbl_top_left"
						},children:[
							{attr:{
								tagname:"thead",
								id:"lstvw_thead_top_left"
							},children:[
								{attr:{
									tagname:"tr"
								},children:[
									{attr:{
										tagname:"th"
									},children:[
										{attr:{
											tagname:"input",
											type :"button",
											id:"lstvw_btn_all",
											value:"all",
											onclick : eventFuncs.btnAllOnClick ,
											className:"_lstvw_left_inner_"
										}},
										{attr:{
											tagname:"span",
											innerHTML :"Target",
											className:"_lstvw_left_inner_"
										}}
									]}
								]}
							]}
						]},
						{attr:{
							tagname:"table",
							id:"lstvw_tbl_body_left"
						},children:[
							{attr:{
								tagname:"thead",
								id:"lstvw_thead_body_left"
							},children:[
								
							]}
						]},
						{attr:{
							tagname:"table",
							id:"lstvw_tbl_top_right"
						},children:[
							{attr:{
								tagname:"thead",
								id:"lstvw_thead_top_right"
							},children:[
								
							]},
							{attr:{
								tagname:"tbody",
								id:"lstvw_tbody_top_right"
							},children:[
								
							]}
						]},
						{attr:{
							tagname:"table",
							id:"lstvw_tbl_body_right"
						},children:[
							{attr:{
								tagname:"tbody",
								id:"lstvw_tbody_body_right"
							},children:[
								
							]}
						]}
					]}
				]}
			]},
			searchSub:{attr:{
				tagname:"div",
				className:"_lstvw_div_sub_wrap_"
			},children:[
				{attr:{
					tagname:"div",
					className:"_lstvw_div_sub_serach_"
				},children:[
					{attr:{
						tagname:"h1",
						className:"_titles_",
						innerHTML :"Search Criteria"
					}},
					{attr:{
						tagname:"table",
						id:"lstvw_tbl_search"
					},children:[
						{attr:{
							tagname:"thead",
							id:"lstvw_thead_search"
						},children:[
							{attr:{
								tagname:"tr",
								className:"_thead_g_"
							},children:[
								{attr:{
									tagname:"th"
								},children:[
									{attr:{
										tagname:"span",
										innerHTML : "Column Name",
										className:"_lstvw_span_serach_head_inner_"
									}}
								]},
								{attr:{
									tagname:"th"
								},children:[
									{attr:{
										tagname:"span",
										innerHTML : "Not",
										className:"_lstvw_span_serach_head_inner_"
									}}
								]},
								{attr:{
									tagname:"th"
								},children:[
									{attr:{
										tagname:"span",
										innerHTML : "Mode",
										className:"_lstvw_span_serach_head_inner_"
									}}
								]},
								{attr:{
									tagname:"th"
								},children:[
									{attr:{
										tagname:"span",
										innerHTML : "Criteria",
										className:"_lstvw_span_serach_head_inner_"
									}}
								]},
								{attr:{
									tagname:"th"
								},children:[
									{attr:{
										tagname:"span",
										innerHTML : "edit action",
										className:"_lstvw_span_serach_head_inner_"
									}}
								]}
							]}
						]},
						{attr:{
							tagname:"tbody",
							id:"lstvw_tbody_search"
						}},
						{attr:{
							tagname:"tfoot",
							id:"lstvw_tfoot_search"
						},children:[
							{attr:{
								tagname:"tr"
							},children:[
								{attr:{
									tagname:"td",
									className:"_td_dmy_"
								}},
								{attr:{
									tagname:"td",
									colSpan:4
								},children:[
									{attr:{
										tagname:"input",
										type: "button",
										id:"lstvw_btn_search_add",
										className:"_btn_adjust_",
										onclick : eventFuncs.btnSearchAddOnClick ,
										value :"add"
									}}
								]}
							]}
						]}
					]},
					{attr:{
						tagname:"div",
						id:"lstvw_div_sub_search_btn_wrap"
					},children:[
						{attr:{
							tagname:"input",
							type: "button",
							id:"lstvw_btn_search_work",
							onclick : eventFuncs.btnSearchWorkOnClick ,
							value :"search"
						}},
						{attr:{
							tagname:"input",
							type: "button",
							id:"lstvw_btn_search_cancel",
							onclick : eventFuncs.btnCancelOnClick ,
							value :"cancel"
						}}
					]}


				]}
			]},

			trSearchBody:{attr:{
				tagname:"tr"
			},children:[
				{attr:{
					tagname:"td"
				},children:[
				]},
				{attr:{
					tagname:"td"
				},children:[
					{attr:{
						tagname:"input",
						type: "checkbox"
					}}
				]},
				{attr:{
					tagname:"td"
				},children:[
				]},
				{attr:{
					tagname:"td"
				},children:[
					{attr:{
						tagname:"input",
						type: "text",
						onchange : eventFuncs.txtValidate,
						className:"_lstvw_txt_search_def_criteria_ _disp_none_"
					}},
					{attr:{
						tagname:"select",
						className:"_lstvw_slct_search_select_criteria_ _disp_none_"
					},children:[
						{attr:{
							tagname:"option",
							value: "",
							selected:true
						}}
					]},
					{attr:{
						tagname:"select",
						className:"_lstvw_slct_search_bool_criteria_ _disp_none_"
					},children:[
						{attr:{
							tagname:"option",
							value: "",
							selected:true
						}},
						{attr:{
							tagname:"option",
							label: "true",
							value: "1"
						}},
						{attr:{
							tagname:"option",
							label: "false",
							value: "-1"
						}},
						{attr:{
							tagname:"option",
							label: "null",
							value: "0"
						}}
					]},

					{attr:{
						tagname:"filedset",
						className:"_lstvw_fldst_search_rng_criteria_ _disp_none_"
					},children:[
						{attr:{
							tagname:"label",
							innerHTML:"min:",
							className:"_lstvw_lbl_search_rng_criteria_"
						},children:[
							{attr:{
								tagname:"input",
								type: "text",
								onchange : eventFuncs.txtValidateRange,
								className:"_lstvw_txt_search_rng_criteria_"
							}}
						]},
						{attr:{
							tagname:"label",
							innerHTML:"max:",
							className:"_lstvw_lbl_search_rng_criteria_"
						},children:[
							{attr:{
								tagname:"input",
								type: "text",
								onchange : eventFuncs.txtValidateRange,
								className:"_lstvw_txt_search_rng_criteria_"
							}}
						]}
					]}
					


				]},
				{attr:{
					tagname:"td"
				},children:[
					{attr:{
						tagname:"input",
						type: "button",
						value :"delete",
						onclick : eventFuncs.btnSearchDelOnClick ,
						className:"_lstvw_btn_search_del_ _btn_y_"
					}}
				]}
			]},
			searchCol:{attr:{
				tagname:"select",
				className:"_lstvw_slct_search_col_",
				onchange:eventFuncs.slctSearchColOnChange
			},children:[
				{attr:{
					tagname:"option",
					value:-1
				}}
			]},
			searchMode:{attr:{
				tagname:"select",
				className:"_lstvw_slct_search_mode_",
				onchange:eventFuncs.slctSearchModeOnChange
			},children:[
				{attr:{
					tagname:"option",
					value:-1
				}}
			]},

			blkSub:{attr:{
				tagname:"div",
				className:"_lstvw_div_sub_wrap_"
			},children:[
				{attr:{
					tagname:"div",
					className:"_lstvw_div_sub_blk_"
				},children:[
					{attr:{
						tagname:"h1",
						className:"_titles_",
						innerHTML :"Bulk Update"
					}},
					{attr:{
						tagname:"table",
						id:"lstvw_tbl_blkud"
					},children:[
						{attr:{
							tagname:"thead",
							id:"lstvw_thead_blkud"
						},children:[
							{attr:{
								tagname:"tr",
								className:"_thead_g_"
							},children:[
								{attr:{
									tagname:"th"
								},children:[
									{attr:{
										tagname:"span",
										innerHTML : "Column Name",
										className:"_lstvw_span_blkud_head_inner_"
									}}
								]},
								{attr:{
									tagname:"th"
								},children:[
									{attr:{
										tagname:"span",
										innerHTML : "Value",
										className:"_lstvw_span_blkud_head_inner_"
									}}
								]},
								{attr:{
									tagname:"th"
								},children:[
									{attr:{
										tagname:"span",
										innerHTML : "edit action",
										className:"_lstvw_span_blkud_head_inner_"
									}}
								]}
							]}
						]},
						{attr:{
							tagname:"tbody",
							id:"lstvw_tbody_blkud"
						}},
						{attr:{
							tagname:"tfoot",
							id:"lstvw_tfoot_blkud"
						},children:[
							{attr:{
								tagname:"tr"
							},children:[
								{attr:{
									tagname:"td",
									className:"_td_dmy_"
								}},
								{attr:{
									tagname:"td",
									colSpan:2
								},children:[
									{attr:{
										tagname:"input",
										type: "button",
										id:"lstvw_btn_blkud_add",
										className:"_btn_adjust_",
										onclick : eventFuncs.btnBlkudAddOnClick ,
										value :"add"
									}}
								]}
							]}
						]}
					]},
					{attr:{
						tagname:"div",
						id:"lstvw_div_sub_blkud_btn_wrap"
					},children:[
						{attr:{
							tagname:"input",
							type: "button",
							id:"lstvw_btn_blkud_work",
							onclick : eventFuncs.btnBlkudWorkOnClick ,
							className:"_btn_y_",
							value :"update"
						}},
						{attr:{
							tagname:"input",
							type: "button",
							id:"lstvw_btn_blkud_cancel",
							onclick : eventFuncs.btnBlkudCancelOnClick ,
							value :"cancel"
						}}
					]}
				]}
			]},
			trBlkBody:{attr:{
				tagname:"tr"
			},children:[
				{attr:{
					tagname:"td"
				},children:[
					{attr:{
						tagname:"select",
						className:"_lstvw_slct_blkud_col_",
						onchange:eventFuncs.slctBlkUdColOnChange,
						onfocus:eventFuncs.slctBlkUdColOnFocus
					},children:[
					]}
				]},
				{attr:{
					tagname:"td"
				},children:[
				]},
				{attr:{
					tagname:"td"
				},children:[
					{attr:{
						tagname:"input",
						type: "button",
						value :"delete",
						onclick : eventFuncs.btnBlkDelOnClick ,
						className:"_lstvw_btn_blkud_del_ _btn_y_"
					}}
				]}
			]}

		};
		nodeDef.trSearchBody.children[0].children.push( nodeDef.searchCol );
		nodeDef.trSearchBody.children[2].children.push( nodeDef.searchMode );


		var rowSortFunc = function( a , b ){
			var ret = 0;
			//ソート指定が有効かチェックし、有効であれば、指定されたソート関数でソートする。
			if( _U.isIdx( sortSelected.col , a ) && _U.isIdx( sortSelected.odr , arySortFuncs ) ){
				ret = arySortFuncs[ sortSelected.odr ].func( a[ sortSelected.col ] , b[ sortSelected.col ] );
				if( ret != 0 )return ret;
			};

			//各列でソートする。
			for( var i = 0 ; _U.isIdx( i , aryDataIdx4srt ) ; i ++ ){
				ret = _MySort.strcmp( a[ aryDataIdx4srt[ i ] ] , b[ aryDataIdx4srt[ i ] ] );
				if( ret != 0 )return ret;
			};

			//rowIdでソートする。
			return _MySort.numAsc( a[ a.length - 1 ] , b[ b.length - 1 ] );
		};
		var dataSort = function(){
			var objTableData = _tableData._getJoinedTableData();
			var arySorted = objTableData.table;
			arySorted.sort( rowSortFunc );
		};
		var sortAndMoveTr = function(){
			dataSort();
			var objTableData = _tableData._getJoinedTableData();
			for( var i = 0 ; _U.isIdx( i , objTableData.table ) ; i ++ ){
				var rowData = objTableData.table[i];
				var rowId = rowData[ rowData.length - 1 ];
				var trLeft = _D.g( "lstvw_tr_left_" + rowId );
				if( trLeft ){
					_D.aC( _D.par( trLeft ) , trLeft );
				};
				var trRight = _D.g( "lstvw_tr_main_" + rowId );
				_D.aC( _D.par( trRight ) , trRight );
			};
		};
		var disp = function( ){
			//検索結果レスポンスのオブジェクトの取得
			var objTableData = _tableData._getJoinedTableData();
			if( objTableData.table.length >= 500 ){
				_disp.showMessageEz( "cmmn_W10" , [ objTableData.table.length ] , dispMain , function(){ dispMain( true )} );
			}else{
				dispMain();
			};
		};


		var dispMain = function( blUnDispRows ){
			_disp.showMessageEz( "cmmn_1" , ["HEADER INFO"] );
			setTimeout( function(){ dispMainMain(blUnDispRows);} , 0 );
		}
		var dispMainMain = function( blUnDispRows ){
			if( blUnDispRows && mode != "lv" ){
				mode = "lv";
			}

			var main = _D.g("main");
			//ここまででエラーがあった場合は既に画面通知済みのはず。

			main.innerHTML = "";

			//ひとまず、基本の画面要素作成
			mainInner = _D.aCAndCN( main , nodeDef.mainInner );
			searchSubWrap = _D.aCAndCN( main , nodeDef.searchSub );
			blkSubWrap = _D.aCAndCN( main , nodeDef.blkSub );
			_D.show( searchSubWrap , false );
			_D.show( blkSubWrap , false );

			mainInner.dataset.mode = mode;

			//画面部品としての各テーブルを取得
			elmTblTopLeft = _D.g("lstvw_tbl_top_left");
			elmTblTopRight = _D.g("lstvw_tbl_top_right");
			elmTblBodyLeft = _D.g("lstvw_tbl_body_left");
			elmTblBodyRight = _D.g("lstvw_tbl_body_right");

			//画面タイトル部への表名の反映
			tblTbl = _sysData._getData( "tbl" );
			var mainTName = _sysData._tblFind( tblTbl , [{key:"id",value:_this.tblId }] , true )[0].name;
			_D.g("lstvw_span_table_name").innerHTML = _U.htmlEscape( mainTName );

			//検索結果レスポンスのオブジェクトの取得
			var objTableData = _tableData._getJoinedTableData();
			var objTableDataS = _tableData._getSingleTableData( _this.tblId );

			//件数の反映
			_D.g("lstvw_span_row_count").innerHTML = objTableData.table.length + " / " + objTableDataS.table.length;

			//各種データ取得
			var tableInfo = _tableData._getJoinedTableInfo( _this.tblId );

			uqTbl = _sysData._tblFind( _sysData._getData( "uq" , _sysData._getMode.asWTable ) , [{key:"Table",value:_this.tblId }] );
			colTbl = _sysData._getData( "col" );

			var srtTbl = _sysData._getData( "sort" );

			typeTbl = _sysData._getData( "type" );
			modeTbl = _sysData._getData( "mode" );
			typeModeTbl = _sysData._getData( "typeMode" );

			optTbl = _sysData._getData( "opt" );


			//srtTblから取得したデータと固定データを併せて、昇順/降順のソート基本関数配列を作成

			//固定データとして、数値、コードの昇順、降順を作成
			arySortFuncs =[
				{func:_MySort.numAsc,name:"number ascending"},
				{func:_MySort.numDesc,name:"number descending"},
				{func:_MySort.strcmp,name:"code ascending"},
				{func:function( a, b ){return _MySort.strcmp( b , a )},name:"code descending"}
			];
			for( var i = 0 ; _U.isIdx( i , srtTbl ) ; i ++ ){
				var wkSortStr = srtTbl[i].sortStr.replace(/,+/g,",");
				var arySort = [];
				if( wkSortStr != "" ){
					arySort = wkSortStr.split( "," );
				};
				arySortFuncs.push(
					{func:_MySort.getStrSort( arySort ),name:srtTbl[i].name + " ascending"}
				);
				arySortFuncs.push(
					{func:_MySort.getStrSort( arySort , true ),name:srtTbl[i].name + " descending"}
				);
			};



			//tableInfoとcolTblとobjTableDataから、表示させる列の情報を整理する。

			//レスポンスのtable情報から、rlts毎の開始index値を算出する。
			var rltsTops = {};

			var wkIdx = 0;
			for( var i = 0 ; _U.isIdx( i , objTableData.tables ) ; i++ ){
				rltsTops[ objTableData.tables[ i ].relats ] = wkIdx;
				wkIdx += objTableData.tables[ i ].span;
			};

			var defTrDmy ={attr:{
				tagname:"tr",
				className:"_lstvw_tr_dmy_"
			},children:[]};
			var defTr1 ={attr:{
				tagname:"tr"
			},children:[]};
			var defTr2 ={attr:{
				tagname:"tr"
			},children:[]};


			var aryColClrs =[];
			aryColInfo4Search =[];

			aryDataIdx = [];
			aryDataType = [];
			aryDataIdx4srt = [];
			aryFormedColName = [];
			var aryIsPk =[];

			var aryMainTableIdxs = [];

			var colIdx = 0;
			//tableInfoでループする。
			for( var i = 0 ; _U.isIdx( i , tableInfo ) ; i ++ ){

				var tInfo = tableInfo[i];
				var tId = tInfo.tableId;
				var rlts = tInfo.rlts.join();

				var tableNameStr = tInfo.tableName;
				var tableBGClass = "_thead_g_";
				var colColor = "";
				if( rlts != "" ){
					tableNameStr += " (" + tInfo.strRlt +")";
					if( i % 2 == 0 ){
						colColor = "_tbody_w_y_";
						tableBGClass = "_thead_w_y_";
					}else{
						colColor = "_tbody_w_r_";
						tableBGClass = "_thead_w_r_";
					};
				};

				var resTable = _sysData._tblFind( objTableData.tables , [{key:"relats",value:rlts }] , true )[0];
				var colspan = resTable.span;

				//tableの列情報の取得
				var aryTargCol = _sysData._tblFind( colTbl , [{key:"tableId",value:tId }]);

				var tableTopIdx = rltsTops[ rlts ];
				var tableOverIdx = tableTopIdx + colspan;

				var countRealSpan = 0;


				//列情報でループし、ヘッダ2行目を生成すると同時に、各行のインデックス情報を作成
				for( var j = 0 ; _U.isIdx( j , aryTargCol ) ; j ++ ){

					//レスポンスのヘッダ情報から、自身の列のIDを探し出す。
					var blFindCol = false;
					for( var k = tableTopIdx ; k < tableOverIdx ; k ++ ){
						if( objTableData.head[ k ] == aryTargCol[j].id ){
							aryDataIdx.push( k );
							if( rlts == "" ){
								aryMainTableIdxs.push( k );
							};
							blFindCol = true;
						};
					};
					if( ! blFindCol ) continue;
					countRealSpan ++;

					aryColClrs.push( colColor );
					if( rlts == "" && aryTargCol[j].pk == 1 ){
						aryIsPk.push( true );
					}else{
						aryIsPk.push( false );
					};


					var strClass = "_lstvw_col_" + colIdx + "_";

					defTrDmy.children.push({attr:{
						tagname:"td"
					},children:[
						{attr:{
							tagname:"span",
							className:"_lstvw_head_inner_ _default_width_ " + strClass
						}}
					]});

					defTr2.children.push({attr:{
						tagname:"th",
						className : tableBGClass
					},children:[
						{attr:{
							tagname:"span",
							className:"_lstvw_head_inner_ _default_width_ " + strClass,
							title : aryTargCol[j].name
						},children:[
							{attr:{
								tagname:"span",
								innerHTML :_U.htmlEscape( tInfo.tableName + "." ),
								className:"_lstvw_head_inner_tname_4cpy_"
							}},
							_U.htmlEscape( aryTargCol[j].name )
						]}
					]});
					_D.css.del( "._lstvw_ ." + strClass );
					_D.css.add( "._lstvw_ ." + strClass +"{" +aryTargCol[j].css +"}");
					colIdx ++;

					aryFormedColName.push( tInfo.tableName + "." + aryTargCol[j].name );
					aryDataType.push( aryTargCol[j].type );

					//検索用の列情報一覧を作成する。
					aryColInfo4Search.push({
						table:tId,
						relats:rlts,
						col:aryTargCol[j].id,
						type:aryTargCol[j].type,
						colName:tInfo.tableName + "." + aryTargCol[j].name
					});

				};
				if( countRealSpan > 0 ){

					var strTb = "";
					for( var j = 1 ; j < countRealSpan ; j ++ ){
						strTb +="\t";
					};

					defTr1.children.push({attr:{
						tagname:"th",
						colSpan:countRealSpan,
						className : tableBGClass
					},children:[
						{attr:{
							tagname:"span",
							className:"_lstvw_head_inner_ _lstvw_head_join_",
							title : tableNameStr 
						},children:[
							_U.htmlEscape( tableNameStr ),
							{attr:{
								tagname:"span",
								innerHTML : strTb ,
								className:"_lstvw_head_strtb_"
							}}
							
						]}
					]});
				};
			};

			var theadRight = _D.g("lstvw_tbody_top_right");
			var tdmyRight = _D.g("lstvw_thead_top_right");

			var trDmy = _D.aCAndCN( tdmyRight , defTrDmy );
			var trHead1 = _D.aCAndCN( theadRight , defTr1 );
			var trHead2 = _D.aCAndCN( theadRight , defTr2 );

			for( var i = 0 ; _U.isIdx( i , aryIsPk ) ; i ++ ){
				if( aryIsPk[ i ] ){
					_D.lEC( trHead2.children[i] ).dataset.after = "(PK)";
				};
			};

			//trHead2の要素でループし、spanのclientWidthの合計を取得。
			//対応するtrHead1の要素のspanのwidthに指定する。

			var wkTr2ThIdx = 0;
			for( var i = 0 ; _U.isIdx( i , trHead1.children ) ; i ++ ){
				var wkTh1 = trHead1.children[i];
				var sumClientWidth = 0;
				for( var j = 0 ; j < wkTh1.colSpan ; j ++ , wkTr2ThIdx ++ ){
					var wkTh2 = trHead2.children[ wkTr2ThIdx ];
					sumClientWidth += _D.fEC(wkTh2).clientWidth+3;
				};
				_D.fEC( wkTh1 ).style.width = (sumClientWidth-3) +"px";
			};

			elmTblTopLeft.style.display="block";
			if( elmTblTopLeft.clientHeight > elmTblTopRight.clientHeight ){
				trHead2.style.height = ( trHead2.clientHeight + elmTblTopLeft.clientHeight - elmTblTopRight.clientHeight ) + "px";
			}else{
				_D.fEC( _D.fEC( elmTblTopLeft ) ).style.height = elmTblTopRight.clientHeight + "px";
			};

			elmTblBodyLeft.style.top = elmTblTopRight.clientHeight + "px";
			elmTblBodyRight.style.top = elmTblTopRight.clientHeight + "px";

			elmTblTopLeft.style.display = "";
			delete elmTblTopLeft.style.display;

			//ここまでで表ヘッダの出力


			//以下、ソート関連設定

			//ソート対象列の設定
			var slctSortCol = _D.g("lstvw_slct_srt_col");

			slctSortCol.innerHTML ="";

			_D.aCAndCN( slctSortCol , {attr:{
				tagname:"option",
				value:-1,
				label:""
			}} );

			for( var i = 0 ; _U.isIdx( i , aryFormedColName ) ; i ++ ){

				var opt = _D.aCAndCN( slctSortCol , {attr:{
					tagname:"option",
					value:aryDataIdx[i],
					label:aryFormedColName[i]
				}} );
			};
			slctSortCol.value = sortSelected.col;

			//ソート方法の設定
			var slctSortOdr = _D.g("lstvw_slct_srt_odr");

			slctSortOdr.innerHTML ="";
			_D.aCAndCN( slctSortOdr , {attr:{
				tagname:"option",
				value:-1,
				label:""
			}} );

			for( var i = 0 ; _U.isIdx( i , arySortFuncs ) ; i ++ ){

				var opt = _D.aCAndCN( slctSortOdr , {attr:{
					tagname:"option",
					value: i,
					label: arySortFuncs[i].name
				}} );
			};
			slctSortOdr.value = sortSelected.odr;

			//指定外ソート対象列の設定

			//pkの追加
			for( var i = 0 ; _U.isIdx( i , aryIsPk ) ; i++ ){
				if( aryIsPk[i] ){
					aryDataIdx4srt.push( aryDataIdx[ i ] );
				};
			};

			//uqの追加
			for( var i = 0 ; _U.isIdx( i , uqTbl ) ; i++ ){
				for( var j = 0 ; j < objTableData.tables[0].span ; j++ ){

					if( _U.find( objTableData.head[ j ] , aryDataIdx4srt ) != - 1 )continue;

					var uqCol = _sysData._tblFind( uqTbl[i]._children , [{key:"col",value:objTableData.head[ j ] }] , true)[0];
					if( uqCol ){
						aryDataIdx4srt.push( objTableData.head[ j ] );
					};
				};
			};

			//列の追加
			for( var i = 0 ; _U.isIdx( i , aryMainTableIdxs ) ; i++ ){
				if( _U.find( aryMainTableIdxs[i] , aryDataIdx4srt ) == -1 ){
					aryDataIdx4srt.push( aryMainTableIdxs[i] );
				};
			};
			//以上、ソート関連設定

			//ソートの実行
			dataSort();



			if( ! blUnDispRows ){
				//以下、表ボディ部分出力

				var tbodyMain = _D.g("lstvw_tbody_body_right")
				var tbodyLeft = _D.g("lstvw_thead_body_left")
				var timeRag = 0;

				var finMsg = function(){
					_disp.showMessageEz( "cmmn_10" , [ "search and disp" ]  );
				};
				var tableAdjust = function( num ){
					if( !_U.isIdx( num , tbodyMain.children ) ){
						_disp.infoDetailChg( "table re-drowing now..." );
						setTimeout(
							function(){
								tbodyLeft.innerHTML = strChkInnerHTML;
								finMsg();
							}
						 , 50);
						return;
					};
					var strNum4Msg = (num+1) +" / " + tbodyMain.children.length;
					_disp.infoDetailChg( "table adjusting...\r\n"+ strNum4Msg );

					var max = num + 300;
					if( max > tbodyMain.children.length ){
						max = tbodyMain.children.length
					};
					for( var i = num ; i < max  ; i++ ){
						var trMain = tbodyMain.children[i];
						var rowId = trMain.dataset.rowid;
						//左右のtrの高さを揃える。
						var strHeight = "";
						if( trMain.clientHeight > 22 ){
							strHeight = " style='height:" + trMain.clientHeight + "px;'";
						};
						strChkInnerHTML += "<tr class='_lstvw_tr_main_ _tmp_disp_none_' id='lstvw_tr_left_"+rowId+"'"+strHeight+" ><th class='_lstvw_td_main_'><span class='_lstvw_left_inner_'><input type='checkbox' name='lstvw_chk_each' data-rowid='"+rowId+"' /></span></th></tr>";
					};
					setTimeout(function(){tableAdjust(i);} , 0);
				};
				var finDrow = function(){
					if( mode != "lv"){
						tableAdjust(0)
						return;
					};
					finMsg();
				};

				var strInnerHTML = "";
				var strChkInnerHTML = "";

				var DispRag = function( num ){

					if( !_U.isIdx( num , objTableData.table ) ){
						_disp.infoDetailChg( "table re-drowing now..." );
						setTimeout(
							function(){
								if( mode == "lv"){
									tbodyMain.onclick = openDtView;
								};
								tbodyMain.innerHTML = strInnerHTML;
								finDrow();
							}
						 , 50);
						return;
					};

					var max = num + 300;
					if( max > objTableData.table.length ){
						max = objTableData.table.length
					};
					var strNum4Msg = "table data creating...\r\n"+(num+1) +" / " + objTableData.table.length;
					_disp.infoDetailChg( strNum4Msg );
					for( var i = num ; i < max  ; i++ ){
						var colData = objTableData.table[i];
						var rowId = colData[ colData.length - 1 ];

						strInnerHTML += "<tr class='_lstvw_tr_main_";
						strInnerHTML += "' id = 'lstvw_tr_main_"+rowId+"' data-rowid = '"+rowId+"' >";
						for( var j = 0 ; _U.isIdx( j , aryDataIdx ) ; j++ ){
							
							strInnerHTML += "<td class='_lstvw_td_main_ " + aryColClrs[ j ]+"' ><span class='_lstvw_body_inner_ _default_width_ _lstvw_col_" + j +"_' >" + _U.htmlEscape( _tableData._dataConv4HtmlStr( colData[ aryDataIdx[j] ] , aryDataType[ j ] ) )+ "</span></td>";
						};
						strInnerHTML += "</tr>";
					};

					setTimeout(function(){DispRag(i);} , 0);
					

				};
				DispRag(0);
			}

			nodeDef.searchCol.children = [ nodeDef.searchCol.children[0] ]; 

			//検索対象列の生成
			for( var i = 0 ; _U.isIdx( i , aryColInfo4Search ) ; i ++ ){
				nodeDef.searchCol.children.push({attr:{
					tagname:"option",
					value:i,
					label:aryColInfo4Search[i].colName
				}});
			};

			nodeDef.searchMode.children = [ nodeDef.searchMode.children[0] ]; 

			//検索方法の生成
			for( var i = 0 ; _U.isIdx( i , modeTbl ) ; i ++ ){
				nodeDef.searchMode.children.push({attr:{
					tagname:"option",
					value:modeTbl[i].id,
					label:modeTbl[i].name,
					className:"_disp_none_"
				}});
			};

			//更新対象列の生成
			var aryUpdTargCol = _sysData._tblFind( colTbl , [{key:"tableId",value:_this.tblId }]);

			var slctUpdTargCol = nodeDef.trBlkBody.children[ 0 ].children[ 0 ];
			slctUpdTargCol.children = [{attr:{
				tagname:"option",
				value:"",
				label:"",
				selected:true
			}}];
			for( var i = 0 ; _U.isIdx( i , aryUpdTargCol ) ; i ++ ){
				slctUpdTargCol.children.push({attr:{
					tagname : "option",
					value : aryUpdTargCol[i].id ,
					label:aryUpdTargCol[i].name
				}});
			};

			if( blUnDispRows ){
				_disp.infoDetailChg( "table redrow now..." );
				_D.css.del( "._tmp_disp_none_" );
				_disp.infoClose();

				if( mode == "lv"){
					eventFuncs.btnSearchOnClick();
				};	
			}
		};
		this.reload = function(){
			init( { mode : mode } );
		};
	};

	constructorF.prototype = _protoEachDisp;
	_eachDisp.LstV = new constructorF();
}();
delete _;
