Array.prototype.getUnique = function(){ var u = {}, a = []; for(var i = 0, l = this.length; i < l; ++i){ if(u.hasOwnProperty(this[i])) { continue; } a.push(this[i]); u[this[i]] = 1; } return a; } $( function(){ $( '[id$=_searchButton5]' ).each( function(){ initialGrid5( $(this) ); }); $( window ).on( 'load', doOnLoadByGrid( '5' ) ); $('#hiddenArea').hide(); }); $(window).load(function() { var name = ""; $( '[id$=_searchButton5]' ).each( function(){ name = $(this).attr( 'id' ).replace( '_searchButton5', '' ); }); var $gridCondition = $( '#' + name + '_gridCondition5' ); var $currentGrid = $( '#currentGrid', $gridCondition ); var $gridEle = ( $currentGrid.length == 0 ? $( '#' + name + '_grid5' ) : $( '#' + $currentGrid.val() ) ); triggerAddRowsWhenLoad(name,$gridEle); if ($( '#enableAutoNewLine').val() == '1') { var gridId = name+"_grid5"; var colModels = $gridEle.jqGrid( 'getGridParam', 'colModel' ) $.each( colModels, function(){ var name = this.name; var sortable = this.sortable; var thId = gridId + '_' + name; // if( name != 'rn' && sortable ){ if( name != 'rn'){ //$( '#' + thId + ' .s-ico' ).show(); //處理 header 需要折行, 就會折行 $( '#jqgh_' + thId ).css( 'white-space', 'normal' ).css( 'height', 'auto').css( 'padding', '2px' ); } if( !sortable ){ $( '#jqgh_' + gridId +'_' + name ).css( 'cursor', 'default' ); }else{ $( '#' + thId + ' .s-ico' ).show(); } }); } }); function initialGrid5( $searchEle ){ var id = $searchEle.attr( 'id' ); var name = id.replace( '_searchButton5', '' ); var $addButtonEle = $( '#' + name + '_addButton5' ); $addButtonEle.val("SF3 新增表格列"); var $updateButtonEle = $( '#' + name + '_updateButton5' ); var $processButtonEle = $( '#' + name + '_processButton5' ); disableButton( $processButtonEle ); var $printButtonEle = $( '#' + name + '_printButton5' ); disableButton( $printButtonEle ); var $resetButtonEle = $( '#' + name + '_resetButton5' ); var $gridCondition = $( '#' + name + '_gridCondition5' ); checkElement( $gridCondition, name + '_gridCondition5' ); var $currentGrid = $( '#currentGrid', $gridCondition ); var $gridEle = ( $currentGrid.length == 0 ? $( '#' + name + '_grid5' ) : $( '#' + $currentGrid.val() ) ); checkElement( $gridEle, name + '_grid5' ); console.log( 'use grid in initial, gridId:' + $gridEle.attr( 'id' ) ); var $dataForm = $( '#' + name + "_dataForm5" ); checkElement( $dataForm, name + '_dataForm5' ); var $searchRowsLimit = $( '#searchRowsLimit', $gridCondition ); checkElement( $searchRowsLimit, 'searchRowsLimit' ); var $addRowsLimit = $( '#addRowsLimit', $gridCondition ); checkElement( $addRowsLimit, 'addRowsLimit' ); var $disableProcessConfirm = $( '#disableProcessConfirm', $gridCondition ); checkElement( $disableProcessConfirm, 'disableProcessConfirm' ); var $disableCheckOPCode = $( '#disableCheckOPCode', $gridCondition ); var $processConfirmMsg = $( '#processConfirmMsg', $gridCondition ); //checkElement( $processConfirmMsg, 'processConfirmMsg' ); if (parseInt($searchRowsLimit.val()) > parseInt($addRowsLimit.val())) { alert("每頁總筆數限制需大於每頁查詢筆數限制"); } var $addRows = $( '#addRows', $gridCondition ); checkElement( $addRows, 'addRows' ); var $addUrl = $( '#addUrl', $gridCondition ); // checkElement( $addUrl, 'addUrl' ); var $searchUrl = $( '#searchUrl', $gridCondition ); checkElement( $searchUrl, 'searchUrl' ); var $updateUrl = $( '#updateUrl', $gridCondition ); // checkElement( $updateUrl, 'updateUrl' ); var $processUrl = $( '#processUrl', $gridCondition ); checkElement( $processUrl, 'processUrl' ); var $printUrl = $( '#printUrl', $gridCondition ); checkElement( $printUrl, 'printUrl' ); var $rows = $( '#rows', $gridCondition ); checkElement( $rows, 'rows' ); var $page = $( '#page', $gridCondition ); checkElement( $page, 'page' ); var $debugEle = $( '#debug', $gridCondition ); checkElement( $debugEle, 'debug' ); var $isTriggerChangeEventEle = $( '#isTriggerChangeEvent', $gridCondition ); var $autoSelected = $( '#autoSelected', $gridCondition ); var $autoSelectedWhenRows = $( '#autoSelectedWhenRows', $gridCondition ); var $isFillDataToDataForm = $( '#isFillDataToDataForm', $gridCondition ); var debug = ( $debugEle.val() == 'true' ); var isTriggerChangeEvent = ( $isTriggerChangeEventEle.length == 0 ? true : $isTriggerChangeEventEle.val() == 'true' ); var autoSelected = ( $autoSelected.length == 0 ? true : $autoSelected.val() == 'true' ); var autoSelectedWhenRows = ( $autoSelectedWhenRows.length == 0 ? 1 : $autoSelectedWhenRows.val() ); var isFillDataToDataForm = ( $isFillDataToDataForm.length == 0 ? true : $isFillDataToDataForm.val() == 'true' ); var $useQueryConditionClass = $( '#useQueryConditionClass', $gridCondition ); var useQueryConditionClass = false; if($useQueryConditionClass.length != 0 && $useQueryConditionClass.val() == "1"){ console.log("useQueryConditionClass = true"); useQueryConditionClass=true; } var $isResetNonQueryEle = $( '#isResetNonQuery', $gridCondition ); var $focusIdAfterQueryEle = $( '#focusIdAfterQuery', $gridCondition ); var isResetNonQuery = ( $isResetNonQueryEle.length == 0 ? false : $isResetNonQueryEle.val() == 'true' ); var focusIdAfterQuery = ( $focusIdAfterQueryEle.length == 0 ? null : $focusIdAfterQueryEle.val() ); $.subscribe( name + '_sortColTopics5', subscribeSortColTopics5( $processButtonEle,$gridEle, $searchEle, $gridCondition, '5', debug ) ); $.subscribe( name + '_pagingTopics5', subscribePagingTopics5( $searchEle, $gridEle, debug ) ); $.subscribe( name + '_selectRowTopics5', subscribeSelectRowTopics5( $gridEle, $dataForm, $updateButtonEle, $processButtonEle, $printButtonEle, name, isTriggerChangeEvent, isFillDataToDataForm, debug )); $searchEle.bind( 'click', bindClickEventForSearchButton5( $gridEle, $gridCondition, $dataForm, $searchUrl, $rows, $page, autoSelected, autoSelectedWhenRows, name, id, debug ,$searchRowsLimit,useQueryConditionClass,isResetNonQuery,focusIdAfterQuery ) ); $addButtonEle.bind( 'click', bindClickEventForAddButton5( $gridEle, $addRows, $addUrl, $dataForm, name, debug ,$addRowsLimit ) ); $processButtonEle.bind( 'click', bindClickEventForProcessButton5( $gridEle, $gridCondition, $dataForm, $processUrl, $rows, $page, autoSelected, autoSelectedWhenRows, name, id, debug ,$searchRowsLimit,$disableProcessConfirm,$processConfirmMsg,useQueryConditionClass,$disableCheckOPCode ) ); //$printButtonEle.bind( 'click', bindClickEventForPrintButton5( $printUrl, name, debug ) ); $resetButtonEle.bind( 'click', bindClickEventForResetButton5( $gridEle,$dataForm, $updateButtonEle, $processButtonEle, $printButtonEle, name, isTriggerChangeEvent, debug ) ); initialValidation( $dataForm ); initLibraParam($dataForm); } /** * complete * @param $gridEle * @returns {Function} */ function subscribePagingTopics5( $searchEle, $gridEle, debug ){ return function(){ if( debug ) alert( 'run subscribePagingTopics5() function.' ); if(doBeforePaging5( $gridEle.attr( 'id' ) , $gridEle, debug )){ $searchEle.trigger( 'click', $gridEle.jqGrid( 'getGridParam', 'page' ) ); } }; } /** * complete * @param $grid * @param $dataForm * @param name * @returns {Function} */ function subscribeSelectRowTopics5( $gridEle, $dataForm, $updateButtonEle, $processButtonEle, $printButtonEle, name, isTriggerChangeEvent, isFillDataToDataForm, debug ){ return function(){ if( debug ) alert( 'run subscribeSelectRowTopics5() function.' ); console.log( 'subscribeSelectRowTopics5, gridId:' + $gridEle.attr( 'id' ) ); enableButton($processButtonEle); enableButton($printButtonEle); var rowData = $gridEle.jqGrid( 'getRowData', $gridEle.jqGrid( 'getGridParam', 'selrow' ) ); if($( '#autoSelectFirstRow').length != 0 && $( '#autoSelectFirstRow').val() == "1"){ if($( '#' + $gridEle.attr('id')).jqGrid( 'getGridParam', 'selrow' ) != 1){ $( '#' + $gridEle.attr('id') + ' tr' ).eq(1).attr('class', 'ui-widget-content jqgrow ui-row-ltr'); } } doAfterSelect5( name, debug, rowData ); }; } /** * complete * @param $gridEle * @param $gridCondition * @param $searchUrl * @param $rows * @param $page * @param name * @returns {Function} */ function bindClickEventForSearchButton5( $gridEle, $gridCondition, $dataForm, $searchUrl, $rows, $page, autoSelected, autoSelectedWhenRows, name, id, debug,$searchRowsLimit,useQueryConditionClass,isResetNonQuery,focusIdAfterQuery){ return function( event, page ){ if( debug ) alert( 'run bindClickEventForSearchButton5() function.' ); console.log( 'bindClickEventForSearchButton5, gridId:' + $gridEle.attr( 'id' ) ); var data = $( window ).data(); cleanMsgForStatusField(); var copy = true; if( page == undefined || page == 1 ){ page = '1'; var validationAttrNames = [ 'class', 'dateRange', 'minlength', 'rangelength', 'equalLength', 'lessThanDecimal', 'max', 'min', 'range', 'isExistByCode', 'isExistByCode' ]; $( 'input:text,input:password,select,textarea', $dataForm ).filter( ':not([role])' ).each( function(){ var $ele = $(this); $.each( validationAttrNames, function( index, attrName ){ var searchValue = $ele.attr( attrName + '_search' ); var originalValue = $ele.attr( attrName ); if( originalValue != undefined && $.trim( originalValue ) != 0 ) $ele.attr( attrName + '_temp', originalValue ).removeAttr( attrName ); if( searchValue != undefined && $.trim( searchValue ) != 0 ) $ele.get(0).setAttribute( attrName, searchValue ); }); console.log( 'search:', $ele.outerHtml() ); }); if( debug ) alert( 'before validation:' + $dataForm.outerHtml() ); var valid = $dataForm.valid(); $( 'input:text,input:password,select,textarea', $dataForm ).filter( ':not([role])' ).each( function(){ var $ele = $(this); $.each( validationAttrNames, function( index, attrName ){ var tempValue = $ele.attr( attrName + '_temp' ); var originalValue = $ele.attr( attrName ); if( originalValue != null && $.trim( originalValue ) != 0 ) $ele.removeAttr( attrName ); if( tempValue != null && $.trim( tempValue ) != 0 ) $ele.attr( attrName, tempValue ); }); console.log( $ele.outerHtml() ); }); if( debug ) alert( 'after validation:' + $dataForm.outerHtml() ); if(isResetNonQuery) resetNonQueryElement($dataForm); if(focusIdAfterQuery!=null) $('#'+focusIdAfterQuery, $dataForm).focus(); if( !valid ) return false; if( !doBeforeQuery5( name, debug ) ) return false; } else{ //來自 按下下一頁, 上一頁等等的 trigger copy = false; } $rows.val( $gridEle.jqGrid( 'getGridParam', 'rowNum' ) ); $page.val( page ); if( copy ) copyDataFormToCondition5( $gridCondition, $dataForm, id, debug ); settingLibraParam($dataForm); searchByGrid5( $searchUrl, $gridCondition, $gridEle, page, autoSelected, autoSelectedWhenRows, 5, name, debug,$searchRowsLimit ); settingLibraParam($dataForm); if(useQueryConditionClass){ removeConditionInDataForm5( $gridCondition, $dataForm, id, debug ,useQueryConditionClass ); } }; } /** * bind event for add button 5 * (complete) * @param $addUrl * @param name * @returns {Function} */ function bindClickEventForAddButton5( $gridEle,$addRows, $addUrl, $dataForm, name, debug ,$addRowsLimit ){ return function(){ if ($gridEle.jqGrid( 'getGridParam', 'reccount' ) >= $addRowsLimit.val()) { alert("已超過最大新增列數!"); return false; } var rowId = $gridEle.jqGrid( 'getGridParam', 'reccount' ) + 1; if( !doBeforeAdd5( name, debug ) ) return false; for(var i=0; i<$addRows.val(); i++){ $gridEle.jqGrid( 'addRowData', rowId , {}); /** * 連續add 會重複select,所以先resetSelect,再setSelect * */ $gridEle.jqGrid('resetSelection'); $gridEle.jqGrid( 'setSelection', rowId ); $('#opCode'+rowId,$dataForm).find('option:contains(U 更新)').remove(); $('#opCode'+rowId,$dataForm).find('option:contains(D 刪除)').remove(); try{ $('#opCode'+rowId,$dataForm).append(''); }catch(e){ //skip } rowId+=1; } $gridEle.jqGrid('resetSelection'); if( !doAfterAdd5( name, debug ) ) return false; }; } /** * complete * @param $processUrl * @param $dataForm * @param name * @returns {Function} */ function bindClickEventForProcessButton5( $gridEle, $gridCondition, $dataForm, $searchUrl, $rows, $page, autoSelected, autoSelectedWhenRows, name, id, debug, $searchRowsLimit,$disableProcessConfirm,$processConfirmMsg,useQueryConditionClass,$disableCheckOPCode){ return function( event, page ){ if( debug ) alert( 'run bindClickEventForProcessButton5() function.' ); console.log( 'bindClickEventForProcessButton5, gridId:' + $gridEle.attr( 'id' ) ); var data = $( window ).data(); cleanMsgForStatusField(); var copy = true; if( page == undefined ){ page = '1'; var validationAttrNames = [ 'class', 'dateRange', 'minlength', 'rangelength', 'equalLength', 'lessThanDecimal', 'max', 'min', 'range', 'isExistByCode', 'isExistByCode' ]; $( 'input:text,input:password,select,textarea', $dataForm ).filter( ':not([role])' ).each( function(){ var $ele = $(this); $.each( validationAttrNames, function( index, attrName ){ var searchValue = $ele.attr( attrName + '_search' ); var originalValue = $ele.attr( attrName ); if( originalValue != undefined && $.trim( originalValue ) != 0 ) $ele.attr( attrName + '_temp', originalValue ).removeAttr( attrName ); if( searchValue != undefined && $.trim( searchValue ) != 0 ) $ele.get(0).setAttribute( attrName, searchValue ); }); console.log( 'search:', $ele.outerHtml() ); }); if( debug ) alert( 'before validation:' + $dataForm.outerHtml() ); var valid = $dataForm.valid(); $( 'input:text,input:password,select,textarea', $dataForm ).filter( ':not([role])' ).each( function(){ var $ele = $(this); $.each( validationAttrNames, function( index, attrName ){ var tempValue = $ele.attr( attrName + '_temp' ); var originalValue = $ele.attr( attrName ); if( originalValue != null && $.trim( originalValue ) != 0 ) $ele.removeAttr( attrName ); if( tempValue != null && $.trim( tempValue ) != 0 ) $ele.attr( attrName, tempValue ); }); console.log( $ele.outerHtml() ); }); if( debug ) alert( 'after validation:' + $dataForm.outerHtml() ); if( !valid ) return false; } else{ //來自 按下下一頁, 上一頁等等的 trigger copy = false; } $rows.val( $gridEle.jqGrid( 'getGridParam', 'rowNum' ) ); //$page.val( page ); // if( copy ) // copyDataFormToCondition5( $gridCondition, $dataForm, id, debug ); if( !doBeforeProcess5( name, debug ) ) return false; var opAry = new Array(); $( '[id^=opCode]' ).each( function(){ opAry.push($(this).attr('id')); }); var opUniqueAry = opAry.getUnique(); var opCnt=0; for ( var int = 0; int < opUniqueAry.length; int++) { if ($( "[id='"+opUniqueAry[int]+"']" ).val() != '') { opCnt+=1; } } if (opCnt ==0) { if($disableCheckOPCode.val() != "true"){ alert("請選擇處理資料列!"); return false; } } var confirmMsg=""; if ($processConfirmMsg.length == 0){ confirmMsg="確定執行處理功能?"; }else{ confirmMsg=$processConfirmMsg.val(); } if($disableProcessConfirm.val() != "true"){ if( !confirm( confirmMsg ) ) return; } if( copy ) copyDataFormToCondition5( $gridCondition, $dataForm, id, debug ); $cloneDataForm = $dataForm.clone(); searchByGrid5( $searchUrl, $gridCondition, $gridEle, page, autoSelected, autoSelectedWhenRows, 5, name, debug,$searchRowsLimit ); settingLibraParam($dataForm); removeConditionInDataForm5( $gridCondition, $cloneDataForm, id, debug ,useQueryConditionClass); if( !doAfterProcess5( name, debug ) ) return false; }; } /** * complete * @param $dataForm * @param name * @returns {Function} */ function bindClickEventForResetButton5($gridEle, $dataForm, $updateButtonEle, $processButtonEle, $printButtonEle, name, isTriggerChangeEvent, debug ){ return function(){ if( debug ) alert( 'run bindClickEventForResetButton5() function.' ); var name = $dataForm.attr( 'id' ).replace( '_dataForm5', '' ); if( !doBeforeReset5( name, debug ) ) return false; var $gridCondition = $( '#' + name + '_gridCondition5' ); resetCondition5( $gridCondition, debug ); resetValue( $dataForm, isTriggerChangeEvent ); $gridEle.jqGrid( 'clearGridData' ); disableButton( $processButtonEle ); disableButton( $printButtonEle ); cleanMsgForStatusField(); doAfterReset5( name, debug ); }; } /** * * @param $gridCondition * @param $dataForm * @param debug */ function copyDataFormToCondition5( $gridCondition, $dataForm, id, debug ){ var $enableCustomCheckBoxValue = $( '#enableCustomCheckBoxValue', $gridCondition ); var enableCustomCheckBoxValue = false; if($enableCustomCheckBoxValue.length != 0 && $enableCustomCheckBoxValue.val() == "1"){ console.log("copyDataFormToCondition5 enableCustomCheckBoxValue = true"); enableCustomCheckBoxValue=true; } $( 'input[type=text]:not( [role] ), select:not( [role] ), input[type=hidden]:not( [role] ), textarea:not( [role] ), input:radio:checked', $dataForm ).each( function(){ var $eleInDataForm = $(this); var eleId = $eleInDataForm.attr( 'id' ); var $eleInCondition = $( '#' + eleId, $gridCondition ); if( $eleInCondition.length == 0 ){ $eleInCondition = $( '' ); $gridCondition.append( $eleInCondition ); $eleInCondition.attr( 'name', $eleInDataForm.attr( 'name' ) ).attr( 'id', $eleInDataForm.attr( 'id' ) ); if( !debug ) $eleInCondition.hide(); } var value; if( $eleInDataForm.prop( 'tagName' ) == 'TEXTAREA' ){ if ($eleInDataForm.text() == ''){ value = $eleInDataForm.val(); }else{ value = $eleInDataForm.text(); } }else{ value = $eleInDataForm.val(); } $eleInCondition.val( value ); }); $( 'div.checkboxGroup', $dataForm ).each( function(){ var $eleInDataForm = $(this); var eleId = $eleInDataForm.attr( 'id' ); var $eleInCondition = $( '#' + eleId, $gridCondition ); if( $eleInCondition.length == 0 ){ $eleInCondition = $eleInDataForm.clone(); $gridCondition.append( $eleInCondition ); } $eleInCondition.empty(); $( 'input:checkbox:checked,input:radio:checked', $eleInDataForm ).each( function(){ var $checkboxInDataForm = $(this); var $checkboxInCondition = $( '' ); $checkboxInCondition.attr( 'name', $checkboxInDataForm.attr( 'name' ) ).val( $checkboxInDataForm.val() ); $checkboxInCondition.attr( 'id', $checkboxInDataForm.attr( 'id' ) ); $eleInCondition.append( $checkboxInCondition ); }); if( !debug ) $eleInCondition.hide(); }); $( 'input:checkbox', $dataForm ).each( function(){ var $eleInDataForm = $(this); var eleId = $eleInDataForm.attr( 'id' ); var $eleInCondition = $( '#' + eleId, $gridCondition ); //console.log(" copyDataFormToCondition5 checkbox eleId : "+eleId); if( $eleInCondition.length == 0 ){ //console.log(" copyDataFormToCondition5 checkbox $eleInCondition.length = 0 , $eleInDataForm.prop('checked') : " +$eleInDataForm.prop("checked")+" , $eleInDataForm.val() = : "+$eleInDataForm.val()); $tempEle = $eleInDataForm.clone(); //$tempEle.attr('name',$eleInDataForm.attr( 'id' ).substring(0,$eleInDataForm.attr( 'id' ).lastIndexOf('_'))); if($eleInDataForm.prop("checked")){ if(enableCustomCheckBoxValue){ $tempEle.attr('value',$eleInDataForm.val()); }else{ $tempEle.attr('value','1'); } }else{ if(enableCustomCheckBoxValue){ $tempEle.attr('value',' '); }else{ $tempEle.attr('value','0'); } } //$tempEle.attr('type','hidden'); try{ //add replace condition for IE compatibility $gridCondition.append( $tempEle.prop('outerHTML').replace('type="checkbox"','type="hidden"').replace('type=checkbox','type=hidden').replace("type='checkbox'","type='hidden'")); }catch(e){ // error occur , using IE8 } }else{ //console.log(" copyDataFormToCondition5 checkbox $eleInCondition.length != 0 , $eleInDataForm.val()= : "+$eleInDataForm.val()); if($eleInDataForm.prop("checked")){ if(enableCustomCheckBoxValue){ $eleInCondition.attr('value',$eleInDataForm.val()); }else{ $eleInCondition.attr('value','1'); } }else{ $eleInCondition.attr('value',' '); } } }); if( debug ) alert( 'in gridCondition:' + $gridCondition.html() ); } //function operateAllRecordsByParam(cellvalue, options, rowObject){ // // $( 'input[type=text]:not( [role] ), select:not( [role] ), input[type=hidden]:not( [role] ), textarea:not( [role] )', $dataForm ).each( function(){ // var $eleInDataForm = $(this); // var eleId = $eleInDataForm.attr( 'id' ); // var $eleInCondition = $( '#' + eleId, $gridCondition ); // // if( $eleInCondition.length == 0 ){ // $eleInCondition = $( '' ); // $gridCondition.append( $eleInCondition ); // // $eleInCondition.attr( 'name', $eleInDataForm.attr( 'name' ) ).attr( 'id', $eleInDataForm.attr( 'id' ) ); // // if( !debug ) // $eleInCondition.hide(); // } // // var value; // if( $eleInDataForm.prop( 'tagName' ) == 'TEXTAREA' ) // value = $eleInDataForm.text(); // else // value = $eleInDataForm.val(); // // $eleInCondition.val( value ); // }); // // $( 'div.checkboxGroup,div.radioGroup', $dataForm ).each( function(){ // var $eleInDataForm = $(this); // var eleId = $eleInDataForm.attr( 'id' ); // var $eleInCondition = $( '#' + eleId, $gridCondition ); // // if( $eleInCondition.length == 0 ){ // $eleInCondition = $eleInDataForm.clone(); // $gridCondition.append( $eleInCondition ); // } // // $eleInCondition.empty(); // // $( 'input:checkbox:checked,input:radio:checked', $eleInDataForm ).each( function(){ // var $checkboxInDataForm = $(this); // // var $checkboxInCondition = $( '' ); // // $checkboxInCondition.attr( 'name', $checkboxInDataForm.attr( 'name' ) ).val( $checkboxInDataForm.val() ); // // $eleInCondition.append( $checkboxInCondition ); // }); // // if( !debug ) // $eleInCondition.hide(); // }); // // $( 'input:checkbox', $dataForm ).each( function(){ // var $eleInDataForm = $(this); // var eleId = $eleInDataForm.attr( 'id' ); // var $eleInCondition = $( '#' + eleId, $gridCondition ); // // if( $eleInCondition.length == 0 ){ // $tempEle = $eleInDataForm.clone(); // $tempEle.attr('name',$eleInDataForm.attr( 'id' ).substring(0,$eleInDataForm.attr( 'id' ).lastIndexOf('_'))); // if($eleInDataForm.prop("checked")){ // $tempEle.attr('value','checked'); // } // $tempEle.attr('type','hidden'); // $gridCondition.append( $tempEle ); // } // }); // // if( debug ) // alert( 'in gridCondition:' + $gridCondition.html() ); // // return ""; //} function removeConditionInDataForm5( $gridCondition, $dataForm, id, debug ,useQueryConditionClass){ $( 'input[type=text]:not( [role] ), select:not( [role] ), input[type=hidden]:not( [role] ), textarea:not( [role] )', $gridCondition ).each( function(){ var $eleInCondition = $(this); var eleId = $eleInCondition.attr( 'id' ); var $eleInDataForm = $( '#' + eleId, $dataForm ); var $eleInQueryConditionClass = $('.queryCondition[id='+eleId+']',$dataForm); if( $eleInDataForm.length != 0 ){ console.log("removeConditionInDataForm5 useQueryConditionClass : "+useQueryConditionClass+" , eleId : "+eleId+" , $eleInQueryConditionClass.length : "+$eleInQueryConditionClass.length); if (!(useQueryConditionClass && $eleInQueryConditionClass.length != 0)) { $eleInCondition.remove(); } } }); $( 'div.checkboxGroup,div.radioGroup', $gridCondition ).each( function(){ var $eleInCondition = $(this); var eleId = $eleInCondition.attr( 'id' ); var $eleInDataForm = $( '#' + eleId, $dataForm ); if( $eleInDataForm.length != 0 ){ $eleInCondition.remove(); } }); $( 'input:checkbox', $gridCondition ).each( function(){ var $eleInCondition = $(this); var eleId = $eleInCondition.attr( 'id' ); var $eleInDataForm = $( '#' + eleId, $dataForm ); if( $eleInDataForm.length != 0 ){ $eleInCondition.remove(); } }); if( debug ) alert( 'in gridCondition:' + $gridCondition.html() ); } function resetCondition5( $gridCondition, debug ){ $( 'input[type=text]:not( [role] ), select:not( [role] ), input[type=hidden]:not( [role] ), textarea:not( [role] ),input:checkbox', $gridCondition ).each( function(){ var $eleInCondition = $(this); var eleId = $eleInCondition.attr( 'id' ); if(eleId != 'searchUrl' && eleId != 'addUrl' && eleId != 'updateUrl' && eleId != 'processUrl' && eleId != 'printUrl' && eleId != 'searchUrl' && eleId != 'rows' && eleId != 'page' && eleId != 'debug' && eleId != 'enableAutoNewLine' && eleId != 'searchRowsLimit' && eleId != 'addRows' && eleId != 'addRowsWhenLoad' && eleId != 'addRowsLimit' && eleId != 'enableCustomCheckBoxValue' && eleId != 'disableProcessConfirm' && eleId != 'disableCheckOPCode' && eleId != 'useQueryConditionClass' && eleId != 'autoSelectedWhenRows' && eleId != 'sortColumnName' && eleId != 'sortOrder' ){ $eleInCondition.remove(); } }); if( debug ) alert( 'resetCondition5 in gridCondition:' + $gridCondition.html() ); } function doAfterCheckBoxSort( name, debug ){ if( debug ) alert( 'callback doAfterCheckBoxSort(), name:' + name ); } function doBeforeProcess5( name, debug ){ if( debug ) alert( 'callback doBeforeProcess5(), name:' + name ); return true; } function doAfterProcess5( name, debug ){ if( debug ) alert( 'callback doAfterProcess5(), name:' + name ); return true; } function doBeforeQuery5( name, debug ){ if( debug ) alert( 'callback doBeforeQuery5(), name:' + name ); return true; } function doAfterQuery5( name, data, debug ){ if( debug ) alert( 'callback doAfterQuery5(), name:' + name + ', data:' + JSON.stringify( data ) ); } function doAfterSelect5( name, debug, data ){ if( debug ) alert( 'callback doAfterSelect5(), name:' + name + ', data:' + JSON.stringify( data ) ); } function doBeforeAdd5( name, debug ){ if( debug ) alert( 'callback doBeforeAdd5(), name:' + name ); return true; } function doAfterAdd5( name, debug ){ if( debug ) alert( 'callback doAfterAdd5(), name:' + name ); } function doBeforeUpdate5( name, debug ){ if( debug ) alert( 'callback doBeforeUpdate5(), name:' + name ); return true; } function doBeforePaging5( name, $gridEle, debug ){ if( debug ) alert( 'callback doBeforePaging5(), name:' + name ); return true; } function doAfterUpdate5( name, data, debug ){ if( debug ) alert( 'callback doAfterUpdate5(), name:' + name ); } function doBeforeDelete5( name, debug ){ if( debug ) alert( 'callback doBeforeDelete5(), name:' + name ); return true; } function doAfterDelete5( name, data, debug ){ if( debug ) alert( 'callback doAfterDelete5(), name:' + name ); } function doBeforeReset5( name, debug ){ if( debug ) alert( 'callback doBeforeReset5(), name:' + name ); return true; } function doAfterReset5( name, debug ){ if( debug ) alert( 'callback doAfterReset5(), name:' + name ); } function doBeforeValidationByAdd5( name, debug ){ if( debug ) alert( 'callback doBeforeValidationByAdd5(), name:' + name ); } function doBeforeValidationByUpdate5( name, debug ){ if( debug ) alert( 'callback doBeforeValidationByUpdate5(), name:' + name ); } function operateRow(cellvalue, options, rowObject){ return ""; } function operateAddRow(cellvalue, options, rowObject){ var name = ""; $( '[id$=_searchButton5]' ).each( function(){ name = $(this).attr( 'id' ).replace( '_searchButton5', '' ); }); enableButton( $( '#' + name + '_processButton5' ) ); return ""; } function operateUpdateRow(cellvalue, options, rowObject){ var name = ""; $( '[id$=_searchButton5]' ).each( function(){ name = $(this).attr( 'id' ).replace( '_searchButton5', '' ); }); enableButton( $( '#' + name + '_processButton5' ) ); return ""; } function doAfterSelectOpRow(e){ var name = $( '[id$=_searchButton5]' ).attr( 'id' ).replace( '_searchButton5', '' ); enableButton($( '#' + name + '_processButton5' )); } function generateText(name,cellvalue, options, isReadOnly,length,maxSize,css,isDateFormat,isMust, eventType,methodCallByEvent,altValue){ var style=""; var size=""; var maxlength=""; var methodCall=""; var ondblclickEvent=" ondblclick='javascript: dbClickvent(event);' "; var mustTag=""; console.log("isMust "+isMust); if (isMust == true) { mustTag=""; } if (isDateFormat !=null && isDateFormat == "Y") { cellvalue=returnDateFormatter(cellvalue); } if (eventType != null && methodCallByEvent != null) { methodCall = " "+eventType+"='javascript: "+methodCallByEvent+"(event);' "; } if (length != null) { size = " size ='"+length+"' "+" style = 'width: "+length+"px;' "; } if (maxSize != null) { maxlength = " maxlength ='"+maxSize+"' "; } if (isReadOnly) { style="readonly "; } if(css != null){ style=style+"class='"+css+"'"; } if(style == ""){ style="class='detail1 detail1_"+options.rowId+"'"; } if(altValue != null){ style=style+" alt='"+altValue+options.rowId+"' "; } if( typeof cellvalue != "undefined" && cellvalue!=null){ return mustTag+''; }else{ return mustTag+''; } } function generateCustomText(name,cellvalue, options,customValue){ var attribute=""; if (customValue != null) { attribute = " "+customValue+" "; } if( typeof cellvalue != "undefined" && cellvalue!=null){ return ""; }else{ return ""; } } function generateTextArea(name,cellvalue, options,cols,rows,css,onBlurMethod){ var style=""; var onBlurCall=""; var size=""; if (onBlurMethod != null) { onBlurCall = " onblur='javascript: "+onBlurMethod+"(event);' "; } if(css != null){ style="class='"+css+"'"; } if(style == ""){ style="class='detail1 detail1_"+options.rowId+"'"; } if( typeof cellvalue != "undefined" && cellvalue!=null){ return ""; }else{ return ""; } } function generateDropDownBox(name,cellvalue, options,eventType,methodCallByEvent){ var dropDownBox = $('#'+name).clone().wrap('

').parent().html(); var methodCall=""; var agent = navigator.userAgent.toLowerCase(); if (eventType != null && methodCallByEvent != null) { methodCall = " "+eventType+"='javascript: "+methodCallByEvent+"(event);' "; } //console.log("agent : "+agent); //console.log("dropDownBox before replace : "+dropDownBox); dropDownBox = dropDownBox.replace('name="'+name+'"','name="lists['+(parseInt(options.rowId) - 1)+'].'+name+'"'); dropDownBox = dropDownBox.replace('name='+name+'','name=lists['+(parseInt(options.rowId) - 1)+'].'+name+''); dropDownBox = dropDownBox.replace('id="'+name+'"','id="'+name+options.rowId+'"'+methodCall); dropDownBox = dropDownBox.replace('id='+name+'','id='+name+options.rowId+''+methodCall); dropDownBox = dropDownBox.replace(''); }catch(e){ // error occur , using IE8 } rowId+=1; } $gridEle.jqGrid('resetSelection'); } }