(self.webpackChunktimetrex=self.webpackChunktimetrex||[]).push([["awesomebox-AComboBox"],{2897:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{eval("/* provided dependency */ var _ = __webpack_require__(9050);\n/* provided dependency */ var jQuery = __webpack_require__(9755);\n( function( $ ) {\n\n\t$.fn.AComboBox = function( options ) {\n\t\tvar opts = $.extend( {}, $.fn.AComboBox.defaults, options );\n\n\t\tvar label_span = null;\n\n\t\tvar a_dropdown = null;\n\n\t\tvar layout_name = '';\n\n\t\tvar pager_data = null; //use to reset pager data when open dropdown\n\n\t\tvar api_class = null;\n\n\t\tvar api = null; //Related TTAPI.API instance, use to get data\n\n\t\tvar default_columns = null;\t //Default coluns when no layout saved\n\n\t\tvar allow_multiple_selection = false;\n\n\t\tvar do_not_get_real_data = false; //Get full data when only pass id to select Value.\n\n\t\tvar get_real_data_on_multi = false; //Usually only get real data when select has a single value. But punch tags require manual_id of all records.\n\n\t\tvar set_any = false;\n\n\t\tvar set_empty = false;\n\n\t\tvar set_special_empty = false;\n\n\t\tvar set_open = false;\n\n\t\tvar set_default = false;\n\n\t\tvar set_all = false;\n\n\t\tvar select_item = null;\n\n\t\tvar select_items = null;\n\n\t\tvar field = '';\n\n\t\tvar validation_field;\n\n\t\tvar user_generic_api = null;\n\n\t\tvar display_columns = null; //Display columns in ADropDown in jGrid model format\n\n\t\tvar possible_display_columns = null; //Only these columns can be shown when init dispaly columns.\n\n\t\tvar list_view_default_columns = null; //Only these columns can be shown when init dispaly columns.\n\n\t\tvar display_columns_in_columnEditor = null; //Display columns in edit columns\n\n\t\tvar all_columns = null; // All columns when edit columns\n\n\t\tvar column_editor = null;\n\n\t\tvar source_data = null; // This will never change when search in search input. Set it back to dropdown every time when open\n\n\t\tvar id = '';\n\n\t\tvar get_real_data_when_open = false;\n\n\t\tvar set_select_items_when_set_data_provider = false;\n\n\t\tvar $this = null;\n\n\t\tvar a_dropdown_div = null;\n\n\t\tvar is_mouse_over = false;\n\n\t\tvar row_per_page = 0;\n\n\t\tvar show_all = false;\n\n\t\tvar args = null;\n\n\t\tGlobal.addCss( 'global/widgets/awesomebox/AComboBox.css' );\n\n\t\tvar show_search_inputs = true;\n\n\t\tvar tree_mode = false;\n\n\t\tvar on_tree_grid_row_select = false;\n\n\t\tvar key = 'id';\n\n\t\tvar error_string = '';\n\n\t\tvar error_tip_box;\n\n\t\t$this = this;\n\n\t\tvar mass_edit_mode = false;\n\n\t\tvar check_box = null;\n\n\t\tvar enabled = true;\n\n\t\tvar allow_drag_to_order = false;\n\n\t\tvar navigation_mode = false;\n\n\t\tvar args_from_saved_layout = null;\n\n\t\tvar default_args = null;\n\t\t//Use this in Navigation Mode, Keep search filter when open. Don't clean it in onClose if navigation_mode\n\t\t// Now we di this in both navigation and normal (2014/6/7)\n\t\tvar cached_search_inputs_filter = null;\n\n\t\tvar cached_select_grid_search_inputs_filter = null;\n\n\t\tvar cached_sort_filter = null; //Same as above\n\n\t\tvar cached_selected_grid_sort_filter = null; //Same as above\n\n\t\tvar script_name = '';\n\n\t\tvar navigation_mode_source_data_before_open = null;\n\n\t\tvar set_default_args_manually = false; //If set default args outside\n\n\t\tvar addition_source_function = null;\n\n\t\tvar custom_key_name = null;\n\n\t\tvar setRealValueCallBack = null; //Set real data call back function\n\n\t\tvar custom_first_label = null;\n\n\t\tvar added_items = null;\n\n\t\tvar column_option_key = 'columns';\n\n\t\t// set this when close, don't allow awesomebox open until 0.3 sec, this prevent awesomebox close in mousedown, and open in click.\n\t\tvar dontOpenTimer = null;\n\n\t\tvar dontOpen = false;\n\n\t\tvar total_header_width;\n\n\t\t//if init source data right after initcolumns complete\n\t\tvar init_data_immediately = false;\n\n\t\tvar unselect_grid_search_result;\n\n\t\t// don't do column filter base on display columns, use all instead\n\t\t//Use in report edit view. load saved report navigation\n\t\tvar always_search_full_columns = false;\n\n\t\t//Save what letter user current use to do the search\n\t\tvar quick_search_dic = {};\n\n\t\t//Save multi key typed when quick search\n\t\tvar quick_search_typed_keys = '';\n\n\t\tvar select_grid_search_result;\n\n\t\t//use to juedge if need to clear quick_search_typed_keys\n\t\tvar quick_search_timer;\n\n\t\tvar current_open_page = 1;\n\n\t\t//deal with result when doing dropdown search, TimesheetAuthorizationViewControl need this.\n\t\tvar extendDataProcessWhenSearch;\n\n\t\tvar always_include_columns = false;\n//\n//\t\t//Used for modify search result when doing Paging or Searching, For example, used in AccrualBalanceViewController to set correct ids\n//\t\tthis.customSearchResultHandler = null;\n\n\t\t//Used for modify search filter when open awesomebox or do search/sorting and paging. First used in Timehsheet absency_policy awesomebox\n\t\tthis.customSearchFilter = null;\n\n\t\tthis.getCurrentOpenPage = function() {\n\t\t\treturn current_open_page;\n\t\t};\n\n\t\tthis.getPagerData = function() {\n\t\t\treturn pager_data;\n\t\t};\n\n\t\tthis.getHeaderWidth = function() {\n\t\t\treturn total_header_width;\n\t\t};\n\n\t\tthis.setKey = function( val ) {\n\t\t\tkey = val;\n\t\t};\n\n\t\tthis.getDisplayColumns = function() {\n\t\t\treturn display_columns;\n\t\t};\n\n\t\tthis.getLayout = function() {\n\n\t\t\treturn ALayoutCache.layout_dic[layout_name];\n\t\t};\n\n\t\tthis.getAPI = function() {\n\t\t\treturn api;\n\t\t};\n\n\t\tthis.getScriptName = function() {\n\n\t\t\tscript_name = Global.getScriptNameByAPI( api_class );\n\n\t\t\treturn script_name;\n\t\t};\n\n\t\tthis.setCachedSortFilter = function( val ) {\n\t\t\tcached_sort_filter = val;\n\t\t};\n\n\t\tthis.setCachedSelectedGridSortFilter = function( val ) {\n\t\t\tcached_selected_grid_sort_filter = val;\n\t\t};\n\n\t\tthis.setCachedSearchInputsFilter = function( val ) {\n\t\t\tcached_search_inputs_filter = val;\n\t\t};\n\n\t\tthis.setCachedSelectGridSearchInputsFilter = function( val ) {\n\t\t\tcached_select_grid_search_inputs_filter = val;\n\t\t};\n\n\t\tthis.setAllowMultipleSelection = function( val ) {\n\t\t\tallow_multiple_selection = val;\n\n\t\t\tif ( val == true ) {\n\t\t\t\tif ( select_item ) {\n\t\t\t\t\tselect_items = [select_item];\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( select_items && select_items.length > 0 ) {\n\t\t\t\t\tselect_item = select_items[0];\n\t\t\t\t}\n\t\t\t}\n\n\t\t};\n\n\t\tthis.getEnabled = function() {\n\t\t\treturn enabled;\n\t\t};\n\n\t\tthis.setEnabled = function( val ) {\n\t\t\tenabled = val;\n\t\t\tif ( val === false || val === '' ) {\n\t\t\t\t$this.addClass( 'a-combobox-readonly' );\n\t\t\t\tif ( check_box ) {\n\t\t\t\t\tcheck_box.hide();\n\t\t\t\t}\n\t\t\t\tif ( !this.children().eq( 1 ).text() ) {\n\t\t\t\t\tthis.children().eq( 1 ).text( $.i18n._( 'N/A' ) );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t$this.removeClass( 'a-combobox-readonly' );\n\n\t\t\t\tif ( check_box ) {\n\t\t\t\t\tcheck_box.show();\n\t\t\t\t}\n\t\t\t\tif ( !this.children().eq( 1 ).text() === $.i18n._( 'N/A' ) ) {\n\t\t\t\t\tthis.children().eq( 1 ).text( '' );\n\t\t\t\t}\n\t\t\t}\n\n\t\t};\n\n\t\tthis.setCheckBox = function( val ) {\n\t\t\tif ( check_box ) {\n\t\t\t\tcheck_box.children().eq( 0 )[0].checked = val;\n\t\t\t}\n\t\t};\n\n\t\tthis.isChecked = function() {\n\t\t\tif ( check_box ) {\n\t\t\t\tif ( check_box.children().eq( 0 )[0].checked === true ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn false;\n\t\t};\n\n\t\tthis.setMassEditMode = function( val ) {\n\t\t\tmass_edit_mode = val;\n\n\t\t\tif ( mass_edit_mode ) {\n\t\t\t\tcheck_box = $( '
' +\n\t\t\t\t\t'
' );\n\t\t\t\tcheck_box.insertBefore( $( this ) );\n\n\t\t\t\tcheck_box.change( function() {\n\t\t\t\t\t$this.trigger( 'formItemChange', [$this] );\n\t\t\t\t} );\n\n\t\t\t} else {\n\t\t\t\tif ( check_box ) {\n\t\t\t\t\tcheck_box.remove();\n\t\t\t\t\tcheck_box = null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t};\n\n\t\tthis.getItemByIndex = function( index ) {\n\t\t\tvar target_source_data;\n\n\t\t\tif ( navigation_mode && !source_data ) {\n\t\t\t\ttarget_source_data = navigation_mode_source_data_before_open;\n\t\t\t} else {\n\t\t\t\ttarget_source_data = source_data;\n\n\t\t\t\t//Only for single mode\n\t\t\t\tif ( unselect_grid_search_result && unselect_grid_search_result.length > 0 ) {\n\t\t\t\t\ttarget_source_data = unselect_grid_search_result;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( !target_source_data ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tvar result = null;\n\t\t\tresult = target_source_data[index];\n\t\t\treturn result;\n\n\t\t};\n\n\t\tthis.getSelectIndex = function() {\n\n\t\t\tvar target_source_data;\n\n\t\t\tif ( navigation_mode && !source_data ) {\n\t\t\t\ttarget_source_data = navigation_mode_source_data_before_open;\n\t\t\t} else {\n\t\t\t\ttarget_source_data = source_data;\n\n\t\t\t\t//Only for single mode\n\t\t\t\tif ( unselect_grid_search_result && unselect_grid_search_result.length > 0 ) {\n\t\t\t\t\ttarget_source_data = unselect_grid_search_result;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( !select_item || !target_source_data ) { // can't get correct index if source_data is null\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\tvar len = target_source_data.length;\n\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\tvar item = target_source_data[i];\n\t\t\t\tif ( select_item[key] === item[key] ) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn 0;\n\t\t};\n\n\t\tthis.getNextSelectItemId = function() {\n\t\t\tvar retval = null;\n\t\t\t// This function is commonly used by edit views to get the id of the next record from the navigation box, such as during Delete&Next\n\t\t\tvar next_select_item = this.getSelectIndex() + 1;\n\t\t\tvar source_data = this.getSourceData();\n\t\t\tif ( source_data && next_select_item < source_data.length ) {\n\t\t\t\tretval = this.getItemByIndex( next_select_item );\n\t\t\t} else {\n\t\t\t\tretval = null;\n\t\t\t}\n\n\t\t\treturn retval;\n\t\t};\n\n\t\tthis.setErrorStyle = function( errStr, show, isWarning ) {\n\t\t\tif ( isWarning ) {\n\t\t\t\t$( this ).addClass( 'a-warning-tip' );\n\t\t\t} else {\n\t\t\t\t$( this ).addClass( 'a-error-tip' );\n\t\t\t}\n\t\t\terror_string = errStr;\n\n\t\t\tif ( show ) {\n\t\t\t\tthis.showErrorTip();\n\t\t\t}\n\t\t};\n\n\t\tthis.showErrorTip = function( sec ) {\n\n\t\t\tif ( !Global.isSet( sec ) ) {\n\t\t\t\tsec = 2;\n\t\t\t}\n\n\t\t\tif ( !error_tip_box ) {\n\t\t\t\terror_tip_box = Global.loadWidgetByName( WidgetNamesDic.ERROR_TOOLTIP );\n\t\t\t\terror_tip_box = error_tip_box.ErrorTipBox();\n\t\t\t}\n\t\t\tif ( $( this ).hasClass( 'a-warning-tip' ) ) {\n\t\t\t\terror_tip_box.show( this, error_string, sec, true );\n\t\t\t} else {\n\t\t\t\terror_tip_box.show( this, error_string, sec );\n\t\t\t}\n\t\t};\n\n\t\tthis.hideErrorTip = function() {\n\n\t\t\tif ( Global.isSet( error_tip_box ) ) {\n\t\t\t\terror_tip_box.remove();\n\t\t\t}\n\n\t\t};\n\n\t\tthis.clearErrorStyle = function() {\n\t\t\t$( this ).removeClass( 'a-error-tip' );\n\t\t\t$( this ).removeClass( 'a-warning-tip' );\n\t\t\terror_string = '';\n\t\t\tthis.hideErrorTip();\n\t\t};\n\n\t\tthis.setField = function( val ) {\n\t\t\tfield = val;\n\t\t};\n\n\t\tthis.getField = function() {\n\t\t\treturn field;\n\t\t};\n\n\t\tthis.getValidationField = function() {\n\t\t\treturn validation_field;\n\t\t};\n\n\t\tthis.getValue = function( return_full_value ) {\n\t\t\tvar return_value = null;\n\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\tif ( return_full_value ) {\n\t\t\t\t\treturn_value = select_items;\n\t\t\t\t} else {\n\t\t\t\t\treturn_value = [];\n\t\t\t\t\tif ( Global.isArray( select_items ) ) {\n\t\t\t\t\t\t$.each( select_items, function( index, content ) {\n\t\t\t\t\t\t\t// In 1891, one value in select items is null\n\t\t\t\t\t\t\tif ( content ) {\n\t\t\t\t\t\t\t\tif ( Global.isString( content ) || $.type( content ) === 'number' ) {\n\t\t\t\t\t\t\t\t\treturn_value.push( content );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\treturn_value.push( content[key] );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tif ( select_items.length === 0 ) {\n\t\t\t\t\t\t\tif ( set_any ) {\n\t\t\t\t\t\t\t\treturn_value.push( TTUUID.not_exist_id ); // In fact, if the columns can be multiple selected. and no have any options selected, it's should be return an array.\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif ( set_any ) {\n\t\t\t\t\t\t\treturn_value.push( TTUUID.not_exist_id ); // In fact, if the columns can be multiple selected. and no have any options selected, it's should be return an array.\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Return false when no selected value\n\t\t\t\t\tif ( return_value.length === 0 ) {\n\t\t\t\t\t\tif ( set_any ) {\n\t\t\t\t\t\t\treturn_value = TTUUID.not_exist_id;\n\t\t\t\t\t\t} else if ( set_empty ) {\n\t\t\t\t\t\t\treturn_value = TTUUID.zero_id;\n\t\t\t\t\t\t} else if ( set_special_empty ) {\n\t\t\t\t\t\t\treturn_value = TTUUID.not_exist_id;\n\t\t\t\t\t\t} else if ( set_open ) {\n\t\t\t\t\t\t\treturn_value = TTUUID.zero_id;\n\t\t\t\t\t\t} else if ( set_default ) {\n\t\t\t\t\t\t\treturn_value = TTUUID.zero_id;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( return_full_value ) {\n\t\t\t\t\treturn_value = select_item;\n\t\t\t\t} else {\n\t\t\t\t\tif ( select_item ) {\n\n\t\t\t\t\t\tif ( Global.isSet( select_item[key] ) ) {\n\t\t\t\t\t\t\treturn_value = select_item[key];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn_value = select_item;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif ( set_any ) {\n\t\t\t\t\t\t\treturn TTUUID.not_exist_id;\n\t\t\t\t\t\t} else if ( set_empty ) {\n\t\t\t\t\t\t\treturn TTUUID.zero_id;\n\t\t\t\t\t\t} else if ( set_special_empty ) {\n\t\t\t\t\t\t\treturn TTUUID.not_exist_id;\n\t\t\t\t\t\t} else if ( set_open ) {\n\t\t\t\t\t\t\treturn TTUUID.zero_id;\n\t\t\t\t\t\t} else if ( set_default ) {\n\t\t\t\t\t\t\treturn TTUUID.zero_id;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn return_value;\n\t\t};\n\n\t\tthis.setSourceData = function( val ) {\n\t\t\tsource_data = val;\n\n\t\t\tif ( !allow_multiple_selection ) {\n\t\t\t\tif ( val && val.length > 0 ) {\n\t\t\t\t\tif ( set_empty || set_any || set_default || set_open || set_all || set_special_empty ) {\n\t\t\t\t\t\t$this.createFirstItem();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif ( !select_item ) {\n\t\t\t\t\t\t\t//Related to 1825, directly use item not item id, since use item id willl\n\t\t\t\t\t\t\t// trigger getReal data which case problems and not necessary.\n\t\t\t\t\t\t\tthis.setValue( val[0] );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( val && val.length > 0 ) {\n\t\t\t\t\tif ( set_all ) {\n\t\t\t\t\t\t$this.createFirstItem();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( set_select_items_when_set_data_provider && source_data ) {\n\n\t\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\t\tthis.setValue( select_items );\n\t\t\t\t} else {\n\t\t\t\t\tthis.setValue( select_item );\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tthis.getSourceData = function() {\n\n\t\t\tif ( navigation_mode && navigation_mode_source_data_before_open ) {\n\t\t\t\treturn navigation_mode_source_data_before_open;\n\t\t\t}\n\n\t\t\t//if done search, return the result o\n\t\t\tif ( unselect_grid_search_result ) {\n\t\t\t\treturn unselect_grid_search_result;\n\t\t\t}\n\n\t\t\treturn source_data;\n\t\t};\n\n\t\t//Always return source data only\n\t\tthis.getStaticSourceData = function() {\n\t\t\treturn source_data;\n\t\t};\n\n\t\tthis.getRowPerPage = function() {\n\t\t\treturn row_per_page;\n\t\t};\n\n\t\tthis.setAllColumns = function( value ) {\n\t\t\tall_columns = value;\n\t\t};\n\n\t\tthis.setDisplayColumnsForEditor = function( value ) {\n\t\t\tdisplay_columns_in_columnEditor = value;\n\t\t};\n\n\t\tthis.getAllColumns = function() {\n\n\t\t\tif ( possible_display_columns ) {\n\t\t\t\treturn possible_display_columns;\n\t\t\t}\n\t\t\treturn all_columns;\n\t\t};\n\n\t\tthis.getDisplayColumnsForEditor = function() {\n\t\t\treturn display_columns_in_columnEditor;\n\t\t};\n\n\t\tthis.setEmptyValueAndShowLoading = function() {\n\t\t\tvar current_width = $this.find( '.a-combobox-label' ).width();\n\t\t\tthis.setValue( null );\n\t\t\tlabel_span.text( Global.loading_label );\n\t\t\t$this.find( '.a-combobox-label' ).width( current_width + 'px' );\n\t\t};\n\n\t\tthis.setValue = function( val ) {\n\t\t\t// Related to 1891, one case is value is [null] in vacatuon_psea_ids in ROE edit view\n\t\t\tif ( _.isArray( val ) && val.length === 1 && val[0] === null ) {\n\t\t\t\tval = null;\n\t\t\t}\n\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\tif ( !val || $.type( val ) === 'array' ) {\n\t\t\t\t\tthis.setSelectItems( val );\n\t\t\t\t} else if ( $.type( val ) === 'string' || $.type( val ) === 'number' ) {\n\t\t\t\t\tthis.setSelectItems( [val] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( $.type( val ) === 'array' && val.length > 0 ) {\n\t\t\t\t\tval = val[0];\n\t\t\t\t}\n\t\t\t\t//If no default value set first item as default select item\n\t\t\t\t//#1187 - this fix might cause problems but is needed to allow proper selection of default value when zero_uuid is selected.\n\t\t\t\tif ( !val || val == TTUUID.zero_id ) {\n\t\t\t\t\t// if ( !val ) {\n\t\t\t\t\tif ( !set_empty && !set_any && !set_default && !set_open && !set_all && !set_special_empty && source_data && source_data.length > 0 ) {\n\t\t\t\t\t\tthis.setValue( source_data[0] );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.setSelectItem( null );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\n\t\t\t\t\tthis.setSelectItem( val );\n\t\t\t\t}\n\t\t\t}\n\n\t\t};\n\n\t\tthis.getAllowMultipleSelection = function() {\n\t\t\treturn allow_multiple_selection;\n\t\t};\n\n\t\t//Get full data from api, if get a id\n\t\tthis.getRealData = function( val ) {\n\n\t\t\tif ( Global.isSet( api_class ) ) {\n\n\t\t\t\t//Try api awesomebox first\n\t\t\t\tif ( ( !TTUUID.isUUID( val ) && parseInt( val ) <= 0 ) || val == TTUUID.zero_id || val == TTUUID.not_exist_id ) {\n\n\t\t\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\t\t\t$this.setValue( [this.getLocalSelectItem( val )] );\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$this.setValue( this.getLocalSelectItem( val ) );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvar filter = {};\n\t\t\t\t//id is a public member of this class which contains the field id, so we wrapped 'id' in quotes here to show it's not the public member from above.\n\t\t\t\tfilter.filter_data = { 'id': val };\n\n\t\t\t\t//#2289 - If you have an employee who can view subordinate punches but not view subordinate employee, you will see permission denied without sending the permission section.\n\t\t\t\tif ( default_args && Global.isSet( default_args.permission_section ) ) {\n\t\t\t\t\tfilter.permission_section = default_args.permission_section;\n\t\t\t\t}\n\n\t\t\t\tif ( this.customSearchFilter ) {\n\t\t\t\t\tfilter = this.customSearchFilter( filter );\n\t\t\t\t}\n\n\t\t\t\tlabel_span.text( Global.loading_label );\n\n\t\t\t\tapi['get' + custom_key_name]( filter, {\n\t\t\t\t\tonResult: function( result ) {\n\t\t\t\t\t\tvar result_data = result.getResult();\n\n\t\t\t\t\t\tif ( result_data && result_data.length > 0 ) {\n\n\t\t\t\t\t\t\tvar value;\n\t\t\t\t\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\t\t\t\t\tvalue = result_data;\n\t\t\t\t\t\t\t\t$this.setValue( result_data );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tvalue = result_data[0];\n\t\t\t\t\t\t\t\t$this.setValue( result_data[0] );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( setRealValueCallBack ) {\n\t\t\t\t\t\t\tsetRealValueCallBack( value );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tif ( source_data && source_data.length > 0 ) {\n\t\t\t\t\t$.each( source_data, function( index, content ) {\n\n\t\t\t\t\t\t//Make the id match when val is string or number. use == instead ===.\n\t\t\t\t\t\tif ( content[key] == val ) {\n\n\t\t\t\t\t\t\t$this.setValue( content );\n\t\t\t\t\t\t\treturn false; //This is a boolean false, not an integer or UUID.\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t} else {\n\t\t\t\t\tset_select_items_when_set_data_provider = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t};\n\n\t\tthis.getColumnFilter = function() {\n\n\t\t\tif ( always_search_full_columns ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tvar column_filter = {};\n\t\t\tcolumn_filter.is_owner = true;\n\t\t\tcolumn_filter.id = true;\n\t\t\tcolumn_filter.is_child = true;\n\t\t\tcolumn_filter.user_id = true;\n\t\t\tcolumn_filter.first_name = true; //always contains this if it exists\n\t\t\tcolumn_filter.last_name = true; //always contains this if it exists\n\t\t\tcolumn_filter.object_type_id = true;\n\t\t\tcolumn_filter.manual_id = true;\n\t\t\tcolumn_filter.default_item_id = true;\n\t\t\tcolumn_filter.accrual_policy_id = true;\n\t\t\tcolumn_filter.pay_code_id = true;\n\t\t\tcolumn_filter.start_date = true;\n\t\t\tcolumn_filter.end_date = true;\n\t\t\tcolumn_filter.pay_period_id = true;\n\n\t\t\tif ( api && api.className === 'APIUser' ) {\n\t\t\t\tcolumn_filter.pay_period_schedule_id = true;\n\t\t\t\tcolumn_filter.policy_group_id = true;\n\t\t\t\tcolumn_filter.hire_date = true;\n\t\t\t\tcolumn_filter.termination_date = true;\n\t\t\t}\n\n\t\t\t$.each( display_columns, function( key, item ) {\n\t\t\t\tcolumn_filter[item.name] = true;\n\t\t\t} );\n\n\t\t\tif ( always_include_columns && always_include_columns.length > 0 ) {\n\t\t\t\t$.each( always_include_columns, function( key, item ) {\n\t\t\t\t\tcolumn_filter[item] = true;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn column_filter;\n\t\t};\n\n\t\tthis.cleanDropDownValues = function() {\n\t\t\tif ( a_dropdown ) {\n\t\t\t\ta_dropdown.setSelectGridData( [] );\n\t\t\t}\n\t\t};\n\n\t\tthis.setSelectItem = function( val ) {\n\t\t\t//When setting select_item, clear out the select_items (plural) variable so it doesn't contain old data if the dropdown box happens to get switched back to it.\n\t\t\tselect_items = null;\n\n\t\t\tselect_item = val;\n\n\t\t\tif ( val === false || val === '' ) {\n\t\t\t\tthis.setLabel( val );\n\t\t\t\tif ( setRealValueCallBack ) {\n\t\t\t\t\tsetRealValueCallBack( false );\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( $.type( val ) === 'string' || $.type( val ) === 'number' ) {\n\t\t\t\tthis.getRealData( val );\n\t\t\t} else {\n\t\t\t\tthis.setLabel();\n\t\t\t}\n\t\t};\n\n\t\tthis.setSelectItems = function( val ) {\n\t\t\t//When setting select_items (plural), clear out the select_item variable so it doesn't contain old data if the dropdown box happens to get switched back to it.\n\t\t\tselect_item = null;\n\n\t\t\tif ( !val || val.length < 1 ) {\n\t\t\t\tthis.setEmptyLabel();\n\t\t\t\tselect_items = null;\n\t\t\t\tif ( setRealValueCallBack ) {\n\t\t\t\t\tsetRealValueCallBack( false );\n\t\t\t\t}\n\n\t\t\t\tthis.cleanDropDownValues();\n\n\t\t\t\treturn;\n\t\t\t} else if ( val == TTUUID.not_exist_id && set_any ) {\n\t\t\t\tselect_items = val;\n\t\t\t\tthis.setEmptyLabel();\n\t\t\t\tif ( setRealValueCallBack ) {\n\t\t\t\t\tsetRealValueCallBack( false );\n\t\t\t\t}\n\t\t\t\tthis.cleanDropDownValues();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tselect_items = val;\n\n\t\t\tvar len = val.length;\n\n\t\t\tif ( len > 1 ) {\n\t\t\t\tvar item = val[0];\n\t\t\t\tif ( $.type( item ) === 'string' || $.type( item ) === 'number' ) {\n\t\t\t\t\tif ( !do_not_get_real_data ) {\n\t\t\t\t\t\tget_real_data_when_open = true;\n\t\t\t\t\t}\n\t\t\t\t\tif ( get_real_data_on_multi && setRealValueCallBack ) {\n\t\t\t\t\t\t//Required to get values for Multi-select field callbacks. Currently, used to retrieve punch tag manual ids.\n\t\t\t\t\t\t//If this is not done, manual ids will only be retrieved in the scenario there is only one item selected in which case this.getRealData() is called.\n\t\t\t\t\t\t//However, adding this.getRealData() here causes other issues.\n\t\t\t\t\t\tsetRealValueCallBack( val, true );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.setLabel();\n\t\t\t} else {\n\t\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\t\titem = val[i];\n\t\t\t\t\tif ( $.type( item ) === 'string' ||\n\t\t\t\t\t\t$.type( item ) === 'number' ) {\n\t\t\t\t\t\tif ( !do_not_get_real_data ) {\n\t\t\t\t\t\t\tthis.getRealData( item );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif ( !source_data ) {\n\t\t\t\t\t\t\t\tset_select_items_when_set_data_provider = true;\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//set select items\twhich only contains value to select items have label and value\n\t\t\t\t\t\t\tthis.setSelectItems( this.getRealSelectItemsFromSourceData() );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfor ( var key in item ) {\n\t\t\t\t\t\t\t//speical handle for sort field\n\t\t\t\t\t\t\tif ( item[key] === 'asc' || item[key] === 'desc' ) {\n\t\t\t\t\t\t\t\tif ( !source_data ) {\n\t\t\t\t\t\t\t\t\tset_select_items_when_set_data_provider = true;\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.setLabel();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t};\n\n\t\tthis.getSelectItems = function() {\n\t\t\treturn a_dropdown.getSelectItems();\n\t\t}\n\n\t\tthis.getRealSelectItemsFromSourceData = function() {\n\t\t\tvar len = source_data.length;\n\t\t\tvar select_items_len = select_items ? select_items.length : 0; // Fix for JS Exception if select_items is null.\n\t\t\tvar res = [];\n\n\t\t\tfor ( var i = 0; i < select_items_len; i++ ) {\n\t\t\t\tvar select_value = select_items[i];\n\t\t\t\tfor ( var j = 0; j < len; j++ ) {\n\t\t\t\t\tvar source_item = source_data[j];\n\n\t\t\t\t\t//Could be string or number, use ==\n\t\t\t\t\tif ( select_value == source_item[key] ) {\n\t\t\t\t\t\tres.push( source_item );\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn res;\n\t\t};\n\n\t\tthis.setLabel = function() {\n\t\t\tvar label_arr = Array();\n\n\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\tif ( !select_items ) {\n\t\t\t\t\tthis.setEmptyLabel();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvar len = select_items.length;\n\t\t\t\tif ( len === 1 ) {\n\n\t\t\t\t\tvar display_column_len = display_columns.length;\n\t\t\t\t\tfor ( y = 0; y < display_column_len; y++ ) {\n\n\t\t\t\t\t\tif ( display_columns[y].hidden === true ) { //Hidden field for jGgrid, usually is id\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( layout_name === 'global_sort_columns' && select_items[0][display_columns[y].name] === undefined ) {\n\t\t\t\t\t\t\tvar item = select_items[0];\n\n\t\t\t\t\t\t\tfor ( var key in item ) {\n\t\t\t\t\t\t\t\tvar c_value = key + ' | ' + item[key];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t//When sort field has source data, use proper label shown on the dropdown.\n\t\t\t\t\t\t\tif ( source_data ) {\n\t\t\t\t\t\t\t\tfor ( var i = 0; i < source_data.length; i++ ) {\n\t\t\t\t\t\t\t\t\tvar column = source_data[i];\n\n\t\t\t\t\t\t\t\t\tif ( column.value === key ) {\n\t\t\t\t\t\t\t\t\t\tvar c_value = column.label + ' | ' + item[key];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( c_value !== 0 && c_value == '' ) {\n\t\t\t\t\t\t\t\tc_value = '--';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlabel_arr.push( c_value );\n\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvar c_value = select_items[0][display_columns[y].name];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( c_value !== 0 && c_value == '' ) {\n\t\t\t\t\t\t\tc_value = '--';\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( c_value === 0 || c_value ) {\n\t\t\t\t\t\t\tlabel_arr.push( c_value );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( label_arr.length > 0 ) {\n\t\t\t\t\t\tlabel_span.text( label_arr.join( ' | ' ) );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.setEmptyLabel();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlabel_span.text( len + ' ' + $.i18n._( 'items selected' ) );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Error: Uncaught TypeError: Cannot read property 'length' of null in interface/html5/global/widgets/awesomebox/AComboBox.js?v=9.0.6-20151231-140748 line 902\n\t\t\t\tif ( !select_item || !display_columns ) {\n\t\t\t\t\tthis.setEmptyLabel();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tdisplay_column_len = display_columns.length;\n\t\t\t\tfor ( var y = 0; y < display_column_len; y++ ) {\n\t\t\t\t\tif ( display_columns[y].hidden === true ) { //Hidden field for jGgrid, usually is id\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tc_value = select_item[display_columns[y].name];\n\n\t\t\t\t\tif ( c_value !== 0 && c_value == '' ) {\n\t\t\t\t\t\tc_value = '--';\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( c_value === 0 || c_value ) {\n\t\t\t\t\t\tlabel_arr.push( c_value );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( label_arr.length > 0 ) {\n\t\t\t\t\tlabel_span.text( label_arr.join( ' | ' ) );\n\t\t\t\t} else {\n\t\t\t\t\tthis.setEmptyLabel();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t$this.find( '.a-combobox-label' ).width( 'auto' );\n\t\t};\n\n\t\tthis.setEmptyLabel = function() {\n\t\t\tif ( set_any ) {\n\t\t\t\tlabel_span.text( Global.any_item );\n\t\t\t} else if ( set_empty || set_special_empty ) {\n\t\t\t\tif ( layout_name === 'global_tree_column' ) {\n\t\t\t\t\tlabel_span.text( Global.root_item );\n\t\t\t\t} else {\n\t\t\t\t\tlabel_span.text( Global.empty_item );\n\t\t\t\t}\n\t\t\t} else if ( set_default ) {\n\t\t\t\tlabel_span.text( Global.default_item );\n\t\t\t} else if ( set_open ) {\n\t\t\t\tlabel_span.text( Global.open_item );\n\t\t\t} else {\n\t\t\t\tif ( source_data && source_data.length > 0 ) {\n\t\t\t\t\tvar first_item = source_data[0];\n\n\t\t\t\t\tif ( first_item.hasOwnProperty( 'label' ) ) {\n\t\t\t\t\t\tlabel_span.text( first_item.label );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( custom_first_label ) {\n\t\t\t\tlabel_span.text( custom_first_label );\n\t\t\t}\n\n\t\t};\n\n\t\tthis.onColumnSettingSaveFromLayout = function( layout ) {\n\t\t\tvar filter = {};\n\t\t\tfilter.script = 'global_awesomebox_columns';\n\t\t\tfilter.name = layout_name;\n\t\t\tfilter.is_default = 'false';\n\n\t\t\tfilter.data = layout.data;\n\t\t\tfilter.data.type = 10;\n\t\t\tfilter.data.layout_id = layout.id;\n\n\t\t\tif ( ALayoutCache.layout_dic[layout_name] ) {\n\t\t\t\tfilter.id = ALayoutCache.layout_dic[layout_name].id;\n\t\t\t}\n\n\t\t\tuser_generic_api.setUserGenericData( filter, {\n\t\t\t\tonResult: function( res ) {\n\t\t\t\t\tALayoutCache.layout_dic[layout_name] = null;\n\t\t\t\t\t$this.initColumns();\n\t\t\t\t\tsource_data = null; //Reload source data if column changed\n\n\t\t\t\t}\n\t\t\t} );\n\t\t};\n\n\t\tthis.onColumnSettingSave = function( seletedColumns, rowsPerPageNumber, layout_id, filter_data ) {\n\n\t\t\tvar filter = {};\n\t\t\tfilter.script = 'global_awesomebox_columns';\n\t\t\tfilter.name = layout_name;\n\t\t\tfilter.is_default = 'false';\n\t\t\tfilter.type = 1; //ALayoutType.customize\n\n\t\t\tif ( ALayoutCache.layout_dic[layout_name] ) {\n\t\t\t\tfilter.id = ALayoutCache.layout_dic[layout_name].id;\n\t\t\t}\n\n\t\t\tvar select_columns_in_JSON = [];\n\t\t\tvar len = seletedColumns.length;\n\n\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\tvar column_in_JSON = {\n\t\t\t\t\tlabel: seletedColumns[i].label,\n\t\t\t\t\tvalue: seletedColumns[i].value,\n\t\t\t\t\torderValue: seletedColumns[i].orderValue\n\t\t\t\t};\n\t\t\t\tselect_columns_in_JSON.push( column_in_JSON );\n\t\t\t}\n\n\t\t\tfilter.data = {\n\t\t\t\tdisplay_columns: select_columns_in_JSON,\n\t\t\t\trow_per_page: rowsPerPageNumber,\n\t\t\t\tlayout_id: layout_id,\n\t\t\t\tfilter_data: filter_data\n\t\t\t};\n\n\t\t\t//Error: TypeError: user_generic_api is null in /interface/html5/global/widgets/awesomebox/AComboBox.js?v=9.0.0-20150822-090205 line 987\n\t\t\tif ( !user_generic_api ) {\n\t\t\t\tuser_generic_api = TTAPI.APIUserGenericData;\n\t\t\t}\n\t\t\tuser_generic_api.setUserGenericData( filter, {\n\t\t\t\tonResult: function( res ) {\n\t\t\t\t\tALayoutCache.layout_dic[layout_name] = null;\n\n\t\t\t\t\t$this.initColumns();\n\n\t\t\t\t\tsource_data = null; //Reload source data if column changed\n\n\t\t\t\t\t//Reload real data if columns have changed, so they display data for any new columns\n\t\t\t\t\t// We can't just pass in the selected_items verbatim here, we need to parse off the 'id' fields and pass that in as an array instead.\n\t\t\t\t\tif ( $.type( select_items ) === 'array' ) {\n\t\t\t\t\t\tselect_items = select_items.map( function( obj ) {\n\t\t\t\t\t\t\tif ( obj.hasOwnProperty( 'id' ) ) {\n\t\t\t\t\t\t\t\treturn obj['id'];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\t//Don't try to load data from the API if there is no filter criteria, as everything is likely be returned and therefore will be selected.\n\t\t\t\t\t// This would manifest itself by expanding a dropdown without anything selected in it, then changing the columns.\n\t\t\t\t\tif ( select_items ) {\n\t\t\t\t\t\t$this.getRealData( select_items );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t};\n\n\t\t//Set columns, display columns will be used when open AwesomeBox. If no layout saved. Display columns are the default ones set in this.each\n\t\tthis.initColumns = function() {\n\n\t\t\tuser_generic_api = TTAPI.APIUserGenericData;\n\n\t\t\t//Error: TypeError: 'undefined' is not a function (evaluating 'user_generic_api.getUserGenericData') in /interface/html5/global/widgets/awesomebox/AComboBox.js?v=8.0.0-20141117-095711 line 1044\n\t\t\tif ( !user_generic_api || !user_generic_api.getUserGenericData || typeof ( user_generic_api.getUserGenericData ) !== 'function' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( Global.isSet( ALayoutCache.layout_dic[layout_name] ) ) {\n\t\t\t\tif ( ALayoutCache.layout_dic[layout_name].pending ) {\n\t\t\t\t\tTTPromise.add( 'AComboBox', layout_name );\n\t\t\t\t\tTTPromise.wait( 'AComboBox', layout_name, function() {\n\t\t\t\t\t\tinitColumnsFromCache( layout_name );\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tinitColumnsFromCache( layout_name );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t//Set cache to pending to stop multiple calls to the API for the same layout_name.\n\t\t\t\tALayoutCache.layout_dic[layout_name] = { pending: true };\n\t\t\t\tvar filter = {};\n\t\t\t\tfilter.filter_data = { script: 'global_awesomebox_columns', name: layout_name };\n\t\t\t\tuser_generic_api.getUserGenericData( filter, {\n\t\t\t\t\tonResult: function( res ) {\n\n\t\t\t\t\t\tvar resData = res.getResult();\n\t\t\t\t\t\t//Set this here so Column setting dialog can get correct display columns before open Awesomebox\n\t\t\t\t\t\tif ( resData && resData.length > 0 ) {\n\n\t\t\t\t\t\t\tvar data = resData[0].data;\n\n\t\t\t\t\t\t\t//if saved layout is saved view layout. get it\n\t\t\t\t\t\t\tif ( data.type === 10 ) {\n\n\t\t\t\t\t\t\t\tvar columns_result_data = api.getOptions( column_option_key, { async: false } ).getResult();\n\t\t\t\t\t\t\t\tall_columns = Global.buildColumnArray( columns_result_data );\n\n\t\t\t\t\t\t\t\tvar saved_layout_result = user_generic_api.getUserGenericData( {\n\t\t\t\t\t\t\t\t\tfilter_data: {\n\t\t\t\t\t\t\t\t\t\tid: data.layout_id,\n\t\t\t\t\t\t\t\t\t\tdeleted: false\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}, { async: false } ).getResult();\n\n\t\t\t\t\t\t\t\tif ( saved_layout_result && saved_layout_result.length > 0 ) {\n\t\t\t\t\t\t\t\t\tvar saved_layout = saved_layout_result.slice()[0];\n\t\t\t\t\t\t\t\t\tvar new_data = saved_layout.data;\n\t\t\t\t\t\t\t\t\tnew_data.display_columns = $this.buildDisplayColumns( new_data.display_columns );\n\t\t\t\t\t\t\t\t\tnew_data.filter_data = Global.convertLayoutFilterToAPIFilter( saved_layout );\n\t\t\t\t\t\t\t\t\tresData[0].data.display_columns = new_data.display_columns;\n\t\t\t\t\t\t\t\t\tresData[0].data.filter_data = new_data.filter_data;\n\n\t\t\t\t\t\t\t\t\tdata = resData[0].data;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tdata.filter_data = []; // if saved layou is deleted.\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tALayoutCache.layout_dic[layout_name] = resData[0];\n\n\t\t\t\t\t\t\tALayoutCache.layout_dic[$this.getScriptName()] = layout_name; // bind current view name to layout name;\n\n\t\t\t\t\t\t\tif ( Global.isSet( data.type ) && data.type === 10 ) {\n\n\t\t\t\t\t\t\t\tdisplay_columns = data.display_columns;\n\t\t\t\t\t\t\t\tif ( display_columns.length > 0 ) {\n\t\t\t\t\t\t\t\t\tif ( possible_display_columns ) {\n\t\t\t\t\t\t\t\t\t\tdisplay_columns = filterBaseOnPossibleColumns( display_columns );\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tdisplay_columns = Global.convertColumnsTojGridFormat( display_columns, layout_name, function( width ) {\n\t\t\t\t\t\t\t\t\t\ttotal_header_width = width;\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} else if ( list_view_default_columns ) {\n\t\t\t\t\t\t\t\t\tdisplay_columns = list_view_default_columns;\n\t\t\t\t\t\t\t\t\tdisplay_columns = filterBaseOnPossibleColumns( display_columns );\n\t\t\t\t\t\t\t\t\tdisplay_columns = Global.convertColumnsTojGridFormat( display_columns, layout_name, function( width ) {\n\t\t\t\t\t\t\t\t\t\ttotal_header_width = width;\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\targs_from_saved_layout = {};\n\t\t\t\t\t\t\t\targs_from_saved_layout.filter_data = data.filter_data;\n\t\t\t\t\t\t\t\targs_from_saved_layout.filter_sort = data.filter_sort;\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\tdisplay_columns = data.display_columns;\n\n\t\t\t\t\t\t\t\t//Happen when save no columns in column setting for navigation mode\n\t\t\t\t\t\t\t\tif ( display_columns.length > 0 ) {\n\t\t\t\t\t\t\t\t\tif ( possible_display_columns ) {\n\t\t\t\t\t\t\t\t\t\tdisplay_columns = filterBaseOnPossibleColumns( display_columns );\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tdisplay_columns = Global.convertColumnsTojGridFormat( display_columns, layout_name, function( width ) {\n\t\t\t\t\t\t\t\t\t\ttotal_header_width = width;\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} else if ( list_view_default_columns ) {\n\t\t\t\t\t\t\t\t\tdisplay_columns = list_view_default_columns;\n\t\t\t\t\t\t\t\t\tdisplay_columns = filterBaseOnPossibleColumns( display_columns );\n\t\t\t\t\t\t\t\t\tdisplay_columns = Global.convertColumnsTojGridFormat( display_columns, layout_name, function( width ) {\n\t\t\t\t\t\t\t\t\t\ttotal_header_width = width;\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\trow_per_page = data.row_per_page;\n\t\t\t\t\t\t\t\targs_from_saved_layout = null;\n//\t\t\t\t\t\t\tif ( !navigation_mode && !set_default_args_manually ) {\n//\t\t\t\t\t\t\t\tdefault_args = null;\n//\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t//If set possible columns, use it\n\t\t\t\t\t\t\tif ( list_view_default_columns ) {\n\t\t\t\t\t\t\t\tdisplay_columns = list_view_default_columns;\n\t\t\t\t\t\t\t\tdisplay_columns = filterBaseOnPossibleColumns( display_columns );\n\t\t\t\t\t\t\t\tdisplay_columns = Global.convertColumnsTojGridFormat( display_columns, layout_name, function( width ) {\n\t\t\t\t\t\t\t\t\ttotal_header_width = width;\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tALayoutCache.layout_dic[layout_name] = false;\n\t\t\t\t\t\t\trow_per_page = 0;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( init_data_immediately ) {\n\t\t\t\t\t\t\t$this.initSourceData();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tTTPromise.resolve( 'AComboBox', layout_name );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t};\n\n\t\tvar initColumnsFromCache = function( layout_name ) {\n\t\t\t//Set this here so Column setting dialog can get correct display columns before open Awesomebox\n\t\t\tif ( Global.isSet( ALayoutCache.layout_dic[layout_name].data ) ) {\n\n\t\t\t\tvar data = ALayoutCache.layout_dic[layout_name].data;\n\n\t\t\t\tif ( Global.isSet( data.type ) && data.type === 10 ) {\n\t\t\t\t\tdisplay_columns = data.display_columns;\n\n\t\t\t\t\tif ( display_columns.length > 0 ) {\n\t\t\t\t\t\tif ( possible_display_columns ) {\n\t\t\t\t\t\t\tdisplay_columns = filterBaseOnPossibleColumns( display_columns );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tdisplay_columns = Global.convertColumnsTojGridFormat( display_columns, layout_name, function( width ) {\n\t\t\t\t\t\t\ttotal_header_width = width;\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else if ( list_view_default_columns ) {\n\t\t\t\t\t\tdisplay_columns = list_view_default_columns;\n\t\t\t\t\t\tdisplay_columns = filterBaseOnPossibleColumns( display_columns );\n\t\t\t\t\t\tdisplay_columns = Global.convertColumnsTojGridFormat( display_columns, layout_name, function( width ) {\n\t\t\t\t\t\t\ttotal_header_width = width;\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\targs_from_saved_layout = {};\n\t\t\t\t\targs_from_saved_layout.filter_data = data.filter_data;\n\t\t\t\t\targs_from_saved_layout.filter_sort = data.filter_sort;\n\n\t\t\t\t} else {\n\t\t\t\t\tdisplay_columns = data.display_columns;\n\n\t\t\t\t\tif ( display_columns.length > 0 ) {\n\t\t\t\t\t\tif ( possible_display_columns ) {\n\t\t\t\t\t\t\tdisplay_columns = filterBaseOnPossibleColumns( display_columns );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tdisplay_columns = Global.convertColumnsTojGridFormat( display_columns, layout_name, function( width ) {\n\t\t\t\t\t\t\ttotal_header_width = width;\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else if ( possible_display_columns ) {\n\t\t\t\t\t\tdisplay_columns = possible_display_columns;\n\t\t\t\t\t}\n\t\t\t\t\trow_per_page = data.row_per_page;\n\t\t\t\t\tif ( !navigation_mode && !set_default_args_manually ) {\n\t\t\t\t\t\tdefault_args = null;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tif ( list_view_default_columns ) {\n\t\t\t\t\tdisplay_columns = list_view_default_columns;\n\t\t\t\t\tdisplay_columns = filterBaseOnPossibleColumns( display_columns );\n\t\t\t\t\tdisplay_columns = Global.convertColumnsTojGridFormat( display_columns, layout_name, function( width ) {\n\t\t\t\t\t\ttotal_header_width = width;\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\trow_per_page = 0;\n\t\t\t}\n\t\t\tif ( init_data_immediately ) {\n\t\t\t\t$this.initSourceData();\n\t\t\t}\n\t\t}\n\n\t\tvar filterBaseOnPossibleColumns = function( display_columns ) {\n\n\t\t\t//Error: Unable to get property 'length' of undefined or null reference in /interface/html5/global/widgets/awesomebox/AComboBox.js?v=8.0.0-20141230-125406 line 1169\n\t\t\tif ( !possible_display_columns ) {\n\t\t\t\treturn display_columns;\n\t\t\t}\n\n\t\t\tvar len = possible_display_columns.length;\n\n\t\t\tvar result = [];\n\t\t\tfor ( var j = 0; j < display_columns.length; j++ ) {\n\t\t\t\tvar dis_column = display_columns[j];\n\t\t\t\tvar found = false;\n\t\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\t\tvar column = possible_display_columns[i];\n\t\t\t\t\tif ( column.value === dis_column.value ) {\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( found ) {\n\t\t\t\t\tresult.push( dis_column );\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( result.length === 0 ) {\n\t\t\t\tresult = possible_display_columns;\n\t\t\t}\n\n\t\t\treturn result;\n\n\t\t};\n\n\t\tthis.getId = function() {\n\t\t\treturn id;\n\t\t};\n\n\t\t//update source data to new saved item, happens in timesheet view, edit employee\n\t\tthis.updateSelectItem = function( new_item ) {\n\t\t\tselect_item = new_item;\n\t\t\tif ( source_data ) {\n\n\t\t\t\tfor ( var i = 0; i < source_data.length; i++ ) {\n\t\t\t\t\tvar content = source_data[i];\n\t\t\t\t\tif ( content.id === new_item.id ) {\n\t\t\t\t\t\tsource_data[i] = new_item;\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\t\tthis.getADropDown = function() {\n\t\t\treturn a_dropdown_div;\n\t\t};\n\n\t\tthis.onClose = function( e, target ) {\n\t\t\tif ( a_dropdown == undefined ) {\n\t\t\t\tDebug.Text( 'ERROR: Unable to close AComboBox check to make sure it wasn\\'t instantiated twice.', 'ACombobox.js', 'ACombobox', 'onClose', 10 );\n\t\t\t}\n\n\t\t\t//In the case where a user double clicks a drop-down box to expand it, that can cause it to open the close again immediately, and show a \"-- NONE --\" even though something was previously selected.\n\t\t\t// Therefore if the 'init' promise is still pending because the data is still loading, simply don't close it yet.\n\t\t\tvar pending_promise = TTPromise.isPendingPromises( 'AComboBox', 'init' );\n\t\t\tif ( pending_promise == false ) {\n\t\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\t\t//Re load source_data if select items\n\t\t\t\t\tvar select_items = a_dropdown.getSelectItems();\n\t\t\t\t\t$this.setValue( select_items );\n\t\t\t\t} else {\n\t\t\t\t\tvar select_item = a_dropdown.getSelectItem();\n\t\t\t\t\tif ( select_item ) { // #2593 - null is not an object (evaluating 'select_item._id_')\n\t\t\t\t\t\tif ( !tree_mode ) {\n\t\t\t\t\t\t\t$this.setValue( select_item );\n\t\t\t\t\t\t} else if ( select_item._id_ ) {\n\t\t\t\t\t\t\t$this.setValue( select_item._id_ );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tDebug.Text( 'WARNING: AComboBox::Init promise still pending, cant call setValue()...', 'ACombobox.js', 'ACombobox', 'onClose', 10 );\n\t\t\t}\n\n\t\t\ta_dropdown_div.remove();\n\t\t\tis_mouse_over = false; //When close from esc, this maybe true\n\t\t\tLocalCacheData.openAwesomeBox = null;\n\t\t\tif ( a_dropdown.isChanged() || layout_name === 'global_sort_columns' ) {\n\t\t\t\tif ( check_box ) {\n\t\t\t\t\t$this.setCheckBox( true );\n\t\t\t\t}\n\t\t\t\t$this.trigger( 'formItemChange', [$this] );\n\t\t\t}\n\t\t\t$this.trigger( 'onClose', [$this] );\n\t\t\tdontOpen = true;\n\t\t\tdontOpenTimer = setTimeout( function() {\n\t\t\t\tdontOpen = false;\n\t\t\t}, 200 );\n\t\t\t$this.find( '.focus-input' ).focus();\n\t\t};\n\n\t\t//set next or last item when key down, call from main.js\n\t\tthis.selectNextItem = function( e ) {\n\n\t\t\tvar select_index = this.getSelectIndex();\n\t\t\tvar next_index;\n\t\t\tvar target_grid;\n\t\t\tif ( e.keyCode === 40 ) { //Down\n\t\t\t\te.preventDefault();\n\t\t\t\tif ( !allow_multiple_selection ) {\n\t\t\t\t\tif ( select_index === 0 ) {\n\t\t\t\t\t\tnext_index = 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnext_index = select_index + 1;\n\t\t\t\t\t}\n\t\t\t\t\tvar next_select_item = this.getItemByIndex( next_index );\n\n\t\t\t\t\tif ( !next_select_item ) {\n\t\t\t\t\t\tnext_index = next_index - 1;\n\t\t\t\t\t\tnext_select_item = this.getItemByIndex( next_index );\n\t\t\t\t\t}\n\t\t\t\t\tselect_item = next_select_item;\n\t\t\t\t\ta_dropdown.setSelectItem( next_select_item );\n\t\t\t\t\ta_dropdown.setIsChanged( true );\n\t\t\t\t}\n\t\t\t} else if ( e.keyCode === 38 ) { //Up\n\t\t\t\te.preventDefault();\n\t\t\t\tif ( !allow_multiple_selection ) {\n\t\t\t\t\tif ( select_index === 0 ) {\n\t\t\t\t\t\tnext_index = 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnext_index = select_index - 1;\n\t\t\t\t\t}\n\n\t\t\t\t\tnext_select_item = this.getItemByIndex( next_index );\n\t\t\t\t\tselect_item = next_select_item;\n\t\t\t\t\ta_dropdown.setSelectItem( next_select_item );\n\t\t\t\t\ta_dropdown.setIsChanged( true );\n\t\t\t\t}\n\t\t\t} else if ( e.keyCode === 39 ) { //right\n\t\t\t\tif ( allow_multiple_selection && !$( e.target ).hasClass( 'search-input' ) ) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\ta_dropdown.onUnSelectGridDoubleClick();\n\t\t\t\t\ta_dropdown.setIsChanged( true );\n\t\t\t\t}\n\t\t\t} else if ( e.keyCode === 37 ) { //left\n\t\t\t\tif ( allow_multiple_selection && !$( e.target ).hasClass( 'search-input' ) ) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\ta_dropdown.onSelectGridDoubleClick();\n\t\t\t\t\ta_dropdown.setIsChanged( true );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( quick_search_timer ) {\n\t\t\t\t\tclearTimeout( quick_search_timer );\n\t\t\t\t}\n\t\t\t\tvar focus_target = $( ':focus' );\n\t\t\t\tif ( focus_target.length > 0 && $( focus_target[0] ).hasClass( 'search-input' ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tquick_search_timer = setTimeout( function() {\n\t\t\t\t\tquick_search_typed_keys = '';\n\t\t\t\t}, 750 );\n\t\t\t\te.preventDefault();\n\n\t\t\t\tquick_search_typed_keys = quick_search_typed_keys + String.fromCharCode( e.which ).toLowerCase();\n\t\t\t\tDebug.Text( 'Quick search typed keys: ' + quick_search_typed_keys, 'AComboBox.js', 'AComboBox', 'selectNextItem', 10 );\n\t\t\t\tvar trimmed_quick_search_typed_keys = quick_search_typed_keys.trim();\n\n\t\t\t\tif ( allow_multiple_selection || tree_mode ) {\n\t\t\t\t\tif ( trimmed_quick_search_typed_keys ) {\n\t\t\t\t\t\ttarget_grid = a_dropdown.getFocusInSeletGrid() ? a_dropdown.getSelectGrid() : a_dropdown.getUnSelectGrid();\n\n\t\t\t\t\t\tvar search_index = quick_search_dic[trimmed_quick_search_typed_keys] ? quick_search_dic[trimmed_quick_search_typed_keys] : 0;\n\t\t\t\t\t\tvar tds = $( target_grid.grid.find( 'tr' ).find( 'td:eq(1)' ).filter( function() {\n\t\t\t\t\t\t\treturn $.text( [this] ).toLowerCase().indexOf( trimmed_quick_search_typed_keys ) == 0;\n\t\t\t\t\t\t} ) );\n\t\t\t\t\t\tvar td;\n\t\t\t\t\t\tif ( search_index > 0 && search_index < tds.length ) {\n\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsearch_index = 0;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttd = $( tds[search_index] );\n\t\t\t\t\t\ta_dropdown.unSelectAll( target_grid.grid, true );\n\t\t\t\t\t\t//next_index = td.parent().index() - 1;\n\n\t\t\t\t\t\tvar next_select_item = false;\n\t\t\t\t\t\tvar grid_data = target_grid.getData();\n\t\t\t\t\t\tfor ( var z = 0; z < grid_data.length; z++ ) {\n\t\t\t\t\t\t\tif ( grid_data[z].id == td.parents( 'tr' ).attr( 'id' ) ) {\n\t\t\t\t\t\t\t\tnext_select_item = grid_data[z];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tselect_item = next_select_item;\n\n\t\t\t\t\t\ta_dropdown.setSelectItem( next_select_item, target_grid );\n\t\t\t\t\t\ta_dropdown.setIsChanged( true );\n\t\t\t\t\t\tquick_search_dic = {};\n\t\t\t\t\t\tquick_search_dic[trimmed_quick_search_typed_keys] = search_index + 1;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif ( trimmed_quick_search_typed_keys ) {\n\t\t\t\t\t\tsearch_index = quick_search_dic[trimmed_quick_search_typed_keys] ? quick_search_dic[trimmed_quick_search_typed_keys] : 0;\n\t\t\t\t\t\ttds = $( a_dropdown.getUnSelectGrid().grid.find( 'tr' ).find( 'td:first' ).filter( function() {\n\t\t\t\t\t\t\treturn $.text( [this] ).toLowerCase().indexOf( trimmed_quick_search_typed_keys ) == 0;\n\t\t\t\t\t\t} ) );\n\t\t\t\t\t\tif ( search_index > 0 && search_index < tds.length ) {\n\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsearch_index = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttd = $( tds[search_index] );\n\t\t\t\t\t\tnext_index = td.parent().index() - 1;\n\t\t\t\t\t\tnext_select_item = this.getItemByIndex( next_index );\n\t\t\t\t\t\tselect_item = next_select_item;\n\t\t\t\t\t\ta_dropdown.setSelectItem( next_select_item );\n\t\t\t\t\t\tquick_search_dic = {};\n\t\t\t\t\t\tquick_search_dic[trimmed_quick_search_typed_keys] = search_index + 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\t\tthis.gridScrollTop = function() {\n\n\t\t\tif ( !a_dropdown ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ta_dropdown.gridScrollTop();\n\t\t};\n\n\t\tthis.gridScrollDown = function() {\n\n\t\t\tif ( !a_dropdown ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ta_dropdown.gridScrollDown();\n\t\t};\n\n\t\tthis.selectAll = function() {\n\t\t\tif ( !a_dropdown || tree_mode || !allow_multiple_selection ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ta_dropdown.selectAll();\n\n\t\t};\n\n\t\tthis.getIsMouseOver = function() {\n\t\t\treturn is_mouse_over;\n\t\t};\n\n\t\tthis.onShowAll = function( isShowAll ) {\n\t\t\tshow_all = isShowAll;\n\n\t\t\tvar args = this.buildUnSelectGridFilter();\n\t\t\targs = this.addExcludeIDsToFilter( args, a_dropdown.getSelectItems() );\n\n\t\t\tapi['get' + custom_key_name]( args, {\n\t\t\t\tonResult: function( result ) {\n\n\t\t\t\t\tvar result_data = result.getResult();\n\n\t\t\t\t\tif ( !result_data ) {\n\t\t\t\t\t\tresult_data = [];\n\t\t\t\t\t}\n\n\t\t\t\t\tpager_data = result.getPagerData();\n\t\t\t\t\tsource_data = result_data;\n\n\t\t\t\t\tif ( Global.isSet( api ) ) {\n\t\t\t\t\t\tsource_data = Global.formatGridData( source_data, api.key_name );\n\t\t\t\t\t}\n\n\t\t\t\t\ta_dropdown.setUnselectedGridData( source_data );\n\t\t\t\t\t//a_dropdown.setSelectGridData( a_dropdown.getSelectItems() );\n\t\t\t\t\ta_dropdown.setPagerData( pager_data );\n\t\t\t\t}\n\t\t\t} );\n\t\t};\n\n\t\tthis.buildUnSelectGridFilter = function( exclude_ids = null ) {\n\t\t\tvar args = {};\n\t\t\targs.filter_data = {};\n\t\t\targs.filter_columns = $this.getColumnFilter();\n\t\t\targs.filter_items_per_page = row_per_page;\n\n\t\t\tif ( a_dropdown ) {\n\t\t\t\t//use clone so the view search condition not be set when set default args\n\t\t\t\targs.filter_data = Global.clone( a_dropdown.getUnSelectGridMap() );\n\t\t\t\targs.filter_sort = Global.clone( a_dropdown.getUnSelectGridSortMap() );\n\t\t\t}\n\n\t\t\tif ( args_from_saved_layout ) {\n\t\t\t\tif ( Global.isSet( args_from_saved_layout.filter_data ) ) {\n\t\t\t\t\tfor ( var key in args_from_saved_layout.filter_data ) {\n\t\t\t\t\t\tif ( !args.filter_data.hasOwnProperty( key ) ) {\n\t\t\t\t\t\t\targs.filter_data[key] = args_from_saved_layout.filter_data[key];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( args_from_saved_layout && Global.isSet( args_from_saved_layout.permission_section ) ) {\n\t\t\t\t\targs.permission_section = args_from_saved_layout.permission_section;\n\t\t\t\t}\n\n\t\t\t\t//Do not override sort condition\n\t\t\t\tif ( Global.isSet( args_from_saved_layout.filter_sort ) && !args.filter_sort ) {\n\n\t\t\t\t\targs.filter_sort = args_from_saved_layout.filter_sort;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//default_args is set when navigation mode usually. To keep search filter same as list view grid\n\t\t\t//. In BaseController, setEditViewData function\n\t\t\tif ( default_args ) {\n\n\t\t\t\tif ( Global.isSet( default_args.filter_data ) ) {\n\t\t\t\t\tfor ( var key in default_args.filter_data ) {\n\t\t\t\t\t\tif ( !args.filter_data.hasOwnProperty( key ) ) {\n\t\t\t\t\t\t\targs.filter_data[key] = default_args.filter_data[key];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( default_args && Global.isSet( default_args.permission_section ) ) {\n\t\t\t\t\targs.permission_section = default_args.permission_section;\n\t\t\t\t}\n\n\t\t\t\t//Do not override sort condition\n\t\t\t\tif ( Global.isSet( default_args.filter_sort ) && !args.filter_sort ) {\n\n\t\t\t\t\targs.filter_sort = default_args.filter_sort;\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t//If it has additional search condition from outside viewcontroller\n\t\t\tif ( this.customSearchFilter ) {\n\t\t\t\targs = this.customSearchFilter( args );\n\t\t\t}\n\n\t\t\tif ( show_all ) {\n\t\t\t\targs.second_parameter = true;\n\t\t\t}\n\n\t\t\t// When using ACombo, at this point a_dropdown.getSelectItems() might be empty, but $this.getValue()/select_items has the selected IDs instead. They are in a different format though.\n\t\t\t// This is also required in cases where an employee has 50 items, 48 are already selected, and pagination is set to 5 items per row.\n\t\t\t// Then on the unselected side click to sort by \"Last Name\" a couple times. These exclude_ids must be passed to the API so no matter what all the unselected rows are always returned, just in the proper sort order.\n\t\t\tif ( exclude_ids ) {\n\t\t\t\targs = this.addExcludeIDsToFilter( args, exclude_ids );\n\t\t\t}\n\n\t\t\treturn args;\n\t\t};\n\n\t\tthis.addExcludeIDsToFilter = function( args, exclude_ids ) {\n\t\t\tif ( a_dropdown && args && exclude_ids ) { //#2353 - js exception when a_dropdown is not defined yet\n\t\t\t\tvar selected_ids = exclude_ids;\n\t\t\t\tif ( selected_ids && Global.isArray( selected_ids ) && selected_ids.length > 0 && selected_ids[0] != TTUUID.zero_id ) {\n\t\t\t\t\targs.filter_data.exclude_id = [];\n\t\t\t\t\tfor ( var x in selected_ids ) {\n\t\t\t\t\t\t// Issue #2899 - Selected items can either be an array of IDs or an object. Need to account for either situation.\n\t\t\t\t\t\tif ( selected_ids[x].id ) {\n\t\t\t\t\t\t\targs.filter_data.exclude_id.push( selected_ids[x].id );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\targs.filter_data.exclude_id.push( selected_ids[x] );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn args;\n\t\t}\n\n\t\tthis.buildSelectGridFilter = function() {\n\t\t\tvar args = {};\n\t\t\targs.filter_columns = $this.getColumnFilter();\n\t\t\targs.filter_items_per_page = row_per_page;\n\t\t\targs.filter_data = a_dropdown.getSelectGridMap();\n\t\t\targs.filter_sort = a_dropdown.getSelectGridSortMap();\n\t\t\targs.second_parameter = true; //Always set true because we want alwasy set all data out in select grid\n\n\t\t\treturn args;\n\t\t};\n\n\t\tthis.searchIsEmpty = function( a_dropdown ) {\n\t\t\tvar inputs = a_dropdown.find( 'input.search-input' );\n\t\t\tfor ( var i = 0; i < inputs.length; i++ ) {\n\t\t\t\tif ( $( inputs[i] ).val() != $.i18n._( 'click to search' ) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\tthis.onADropDownSearch = function( targetName, page_action, default_select_item, callBack, trigger_form_item_change = true ) {\n\t\t\tvar this_val = this.getValue();\n\t\t\tif ( targetName == 'select_grid' && this_val.length == 0 || ( targetName == 'select_grid' && this_val.length == 1 && this_val[0] == TTUUID.not_exist_id ) ) {\n\t\t\t\t//#2353 - prevent bug where sorted empty select grid selects everything\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar args = {};\n\t\t\targs.filter_columns = $this.getColumnFilter();\n\t\t\targs.filter_items_per_page = row_per_page;\n\t\t\tif ( targetName === 'unselect_grid' ) {\n\t\t\t\t//When using pagination and first opening the dropdown box, we need to exclude the selected items from the API call\n\t\t\t\t// so the first page will always be populated with a full page of records.\n\t\t\t\targs = $this.buildUnSelectGridFilter( ( ( a_dropdown ) ? a_dropdown.getSelectItems() : null ) ); //Handle JS exception: Error: Cannot read property 'getSelectItems' of null\n\n\t\t\t\t//Error: Unable to get property 'current_page' of undefined or null reference in /interface/html5/global/widgets/awesomebox/AComboBox.js?v=7.4.6-20141027-070003 line 1489\n\t\t\t\tif ( a_dropdown && a_dropdown.getPagerData() ) {\n\t\t\t\t\tif ( LocalCacheData.paging_type === 0 ) {\n\t\t\t\t\t\tif ( page_action === 'next' ) {\n\t\t\t\t\t\t\targs.filter_page = a_dropdown.getPagerData().next_page;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\targs.filter_page = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tswitch ( page_action ) {\n\t\t\t\t\t\t\tcase 'next':\n\t\t\t\t\t\t\t\targs.filter_page = a_dropdown.getPagerData().next_page;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'last':\n\t\t\t\t\t\t\t\targs.filter_page = a_dropdown.getPagerData().previous_page;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'start':\n\t\t\t\t\t\t\t\targs.filter_page = 1;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'end':\n\t\t\t\t\t\t\t\targs.filter_page = a_dropdown.getPagerData().last_page_number;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\targs.filter_page = a_dropdown.getPagerData().current_page;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( parseInt( page_action ) >= 1 ) {\n\t\t\t\t\targs.filter_page = page_action;\n\t\t\t\t}\n\n\t\t\t\tapi['get' + custom_key_name]( args, {\n\t\t\t\t\tonResult: function( result ) {\n\n\t\t\t\t\t\tvar focused_element = $( ':focus' );\n\n\t\t\t\t\t\tvar result_data = result.getResult();\n\n\t\t\t\t\t\tif ( !Global.isArray( result_data ) ) {\n\t\t\t\t\t\t\tresult_data = [];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t//set this outside, to add more data to source_data\n\t\t\t\t\t\tif ( addition_source_function ) {\n\t\t\t\t\t\t\tresult_data = addition_source_function( $this, result_data );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( LocalCacheData.paging_type === 0 && page_action === 'next' ) {\n\t\t\t\t\t\t\tvar current_data = a_dropdown.getUnSelectGridData();\n\t\t\t\t\t\t\tresult_data = current_data.concat( result_data );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( navigation_mode ) {\n\t\t\t\t\t\t\tsource_data = result_data;\n\t\t\t\t\t\t\tpager_data = result.getPagerData();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tunselect_grid_search_result = result_data;\n\t\t\t\t\t\t\tcurrent_open_page = result.getPagerData().current_page;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( $.type( result_data ) != 'array' ) {\n\t\t\t\t\t\t\tresult_data = [];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( !allow_multiple_selection ) {\n\t\t\t\t\t\t\t$this.createFirstItem( result_data );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresult_data = Global.formatGridData( result_data, api.key_name );\n\n\t\t\t\t\t\tif ( extendDataProcessWhenSearch ) {\n\t\t\t\t\t\t\tresult_data = extendDataProcessWhenSearch( result_data );\n\t\t\t\t\t\t}\n\t\t\t\t\t\ta_dropdown && a_dropdown.setUnselectedGridData( result_data );\n\n\t\t\t\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\t\t\t\ta_dropdown && a_dropdown.setSelectGridData( a_dropdown.getSelectItems(), true );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ta_dropdown && a_dropdown.setSelectItem( a_dropdown.getSelectItem() );\n\t\t\t\t\t\t\tif ( default_select_item == 'first' ) {\n\t\t\t\t\t\t\t\t$this.setValue( result_data[0] );\n\t\t\t\t\t\t\t\tif ( trigger_form_item_change == true ) {\n\t\t\t\t\t\t\t\t\t$this.trigger( 'formItemChange', [$this] );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif ( callBack ) {\n\t\t\t\t\t\t\t\t\tcallBack( result_data[0] );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if ( default_select_item == 'last' ) {\n\t\t\t\t\t\t\t\t$this.setValue( result_data[result_data.length - 1] );\n\t\t\t\t\t\t\t\tif ( trigger_form_item_change == true ) {\n\t\t\t\t\t\t\t\t\t$this.trigger( 'formItemChange', [$this] );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif ( callBack ) {\n\t\t\t\t\t\t\t\t\tcallBack( result_data[result_data.length - 1] );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if ( callBack ) {\n\t\t\t\t\t\t\t\tcallBack();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ta_dropdown && a_dropdown.setPagerData( result.getPagerData() );\n\n\t\t\t\t\t\tif ( result_data.length < 1 && a_dropdown.getSelectItems().length < 1 ) {\n\t\t\t\t\t\t\ta_dropdown && a_dropdown.showNoResultCover( 'unselect_grid' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ta_dropdown && a_dropdown.removeNoResultCover( 'unselect_grid' );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ta_dropdown && a_dropdown.getUnSelectGrid().grid.show();\n\n\t\t\t\t\t\tif ( focused_element.length ) {\n\t\t\t\t\t\t\tfocused_element.focus();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t} else {\n\t\t\t\targs = this.buildSelectGridFilter();\n\t\t\t\tif ( args.filter_data.id && args.filter_data.id !== false ) { //prevent returning all available rows when nothing is selected\n\t\t\t\t\tapi['get' + custom_key_name]( args, {\n\t\t\t\t\t\tonResult: function( result ) {\n\t\t\t\t\t\t\tvar result_data = result.getResult();\n\t\t\t\t\t\t\tvar focused_element = $( ':focus' );\n\n\t\t\t\t\t\t\tif ( $.type( result_data ) != 'array' ) {\n\t\t\t\t\t\t\t\tresult_data = [];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tresult_data = Global.formatGridData( result_data, api.key_name );\n\n\t\t\t\t\t\t\ta_dropdown.setSelectGridSearchResult( result_data ); //set as search result\n\n\t\t\t\t\t\t\tif ( result_data.length < 1 ) {\n\t\t\t\t\t\t\t\ta_dropdown.getSelectGrid().grid.clearGridData();\n\t\t\t\t\t\t\t\ta_dropdown.showNoResultCover( 'select_grid' );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\ta_dropdown.removeNoResultCover( 'select_grid' );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\ta_dropdown.setSelectGridDragAble();\n\n\t\t\t\t\t\t\ta_dropdown.getSelectGrid().grid.show();\n\n\t\t\t\t\t\t\tif ( focused_element.length > 0 ) {\n\t\t\t\t\t\t\t\tfocused_element.focus();\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\n\t\t};\n\n\t\tthis.buildDisplayColumns = function( api_display_columns ) {\n\t\t\tvar len = all_columns.length;\n\t\t\tvar len1 = api_display_columns.length;\n\t\t\tvar display_columns = [];\n\n\t\t\tfor ( var j = 0; j < len1; j++ ) {\n\t\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\t\tif ( api_display_columns[j] === all_columns[i].value ) {\n\t\t\t\t\t\tdisplay_columns.push( all_columns[i] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn display_columns;\n\t\t};\n\n\t\tthis.buildDisplayColumnsForEditor = function() {\n\t\t\tvar len = all_columns.length;\n\t\t\tvar len1 = display_columns.length;\n\t\t\tvar result_display_columns = [];\n\t\t\tfor ( var j = 0; j < len1; j++ ) {\n\t\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\t\tif ( !display_columns[j] ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif ( Global.isSet( display_columns[j].name ) ) { //jQgrid column format\n\t\t\t\t\t\tvar name = display_columns[j].name;\n\t\t\t\t\t} else if ( Global.isSet( display_columns[j].value ) ) { //ViewColumn format,\tlabel and value\n\t\t\t\t\t\tname = display_columns[j].value;\n\t\t\t\t\t}\n\t\t\t\t\tif ( name === all_columns[i].value ) {\n\t\t\t\t\t\tresult_display_columns.push( all_columns[i] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result_display_columns;\n\n\t\t};\n\n\t\tthis.getLocalSelectItem = function( val ) {\n\n\t\t\tif ( added_items ) {\n\t\t\t\tfor ( var i = 0; i < added_items.length; i++ ) {\n\t\t\t\t\tif ( val == added_items[i].value ) { //sometime the value is not number\n\t\t\t\t\t\tvar item = {};\n\n\t\t\t\t\t\titem[key] = val;\n\n\t\t\t\t\t\t$.each( display_columns, function( index, content ) {\n\n\t\t\t\t\t\t\titem[content.name] = added_items[i].label;\n\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\treturn item;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn this.getFirstItem();\n\t\t\t} else {\n\t\t\t\treturn this.getFirstItem();\n\t\t\t}\n\t\t};\n\n\t\tthis.getFirstItem = function() {\n\t\t\tvar first_item = {};\n\n\t\t\tfirst_item[key] = TTUUID.zero_id;\n\n\t\t\tif ( set_any || set_all ) {\n\t\t\t\tfirst_item[key] = TTUUID.not_exist_id;\n\t\t\t} else {\n\t\t\t\tfirst_item[key] = TTUUID.zero_id;\n\t\t\t}\n\n\t\t\t$.each( display_columns, function( index, content ) {\n\n\t\t\t\tif ( key !== 'id' ) {\n\t\t\t\t\t//first_item.id = 999; //records id start from 10000\n\t\t\t\t\tfirst_item.id = TTUUID.not_exist_id;\n\t\t\t\t}\n\t\t\t\tif ( set_all ) {\n\t\t\t\t\tfirst_item[content.name] = Global.all_item;\n\t\t\t\t} else if ( set_any ) {\n\t\t\t\t\tfirst_item[content.name] = Global.any_item;\n\t\t\t\t} else if ( set_empty || set_special_empty ) {\n\n\t\t\t\t\tfirst_item[content.name] = Global.empty_item;\n\n\t\t\t\t} else if ( set_open ) {\n\t\t\t\t\tfirst_item[content.name] = Global.open_item;\n\t\t\t\t} else if ( set_default ) {\n\t\t\t\t\tfirst_item[content.name] = Global.default_item;\n\t\t\t\t}\n\n\t\t\t\tif ( custom_first_label ) {\n\t\t\t\t\tfirst_item[content.name] = custom_first_label;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t} );\n\n\t\t\treturn first_item;\n\t\t};\n\n\t\tthis.createFirstItem = function( target_data ) {\n\n\t\t\tvar no_first_item = false;\n\t\t\tif ( !target_data ) {\n\t\t\t\ttarget_data = source_data;\n\t\t\t}\n\n\t\t\tif ( target_data.hasOwnProperty( 0 ) ) {\n\t\t\t\tif ( set_any || set_all ) {\n\t\t\t\t\tif ( target_data[0][key] === TTUUID.not_exist_id ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\tif ( target_data[0][key] === TTUUID.zero_id ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar first_item = {};\n\n\t\t\tfirst_item[key] = TTUUID.zero_id;\n\n\t\t\tif ( set_any || set_all || set_special_empty ) {\n\t\t\t\tfirst_item[key] = TTUUID.not_exist_id;\n\t\t\t} else {\n\t\t\t\tfirst_item[key] = TTUUID.zero_id;\n\t\t\t}\n\n\t\t\t$.each( display_columns, function( index, content ) {\n\n\t\t\t\tif ( key !== 'id' ) {\n\t\t\t\t\t//first_item.id = 999; //records id start from 10000\n\t\t\t\t\tfirst_item.id = TTUUID.not_exist_id; //records id start from 10000\n\t\t\t\t}\n\t\t\t\tif ( set_all ) {\n\t\t\t\t\tfirst_item[content.name] = Global.all_item;\n\t\t\t\t} else if ( set_any ) {\n\t\t\t\t\tfirst_item[content.name] = Global.any_item;\n\t\t\t\t} else if ( set_empty || set_special_empty ) {\n\t\t\t\t\tfirst_item[content.name] = Global.empty_item;\n\t\t\t\t} else if ( set_open ) {\n\t\t\t\t\tfirst_item[content.name] = Global.open_item;\n\t\t\t\t} else if ( set_default ) {\n\t\t\t\t\tfirst_item[content.name] = Global.default_item;\n\t\t\t\t} else {\n\t\t\t\t\tno_first_item = true;\n\t\t\t\t}\n\n\t\t\t\tif ( custom_first_label ) {\n\t\t\t\t\tfirst_item[content.name] = custom_first_label;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t} );\n\n\t\t\tif ( !no_first_item ) {\n\t\t\t\ttarget_data.unshift( first_item );\n\t\t\t}\n\n\t\t};\n\n\t\tthis.checkIfLayoutChanged = function( newDisplayColumns ) {\n\n\t\t\tif ( !display_columns ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif ( !newDisplayColumns ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif ( display_columns.length !== newDisplayColumns.length ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tvar len = display_columns.length;\n\n\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\tvar display_column = display_columns[i];\n\t\t\t\tvar found = false;\n\t\t\t\tfor ( var j = 0; j < len; j++ ) {\n\t\t\t\t\tvar new_display_column = newDisplayColumns[j];\n\t\t\t\t\tif ( new_display_column.name === display_column.name ) {\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( !found ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn false;\n\n\t\t};\n\n\t\tthis.setDefaultArgs = function( val ) {\n\t\t\t$this.default_args = val;\n\t\t\tset_default_args_manually = true;\n\t\t\tdefault_args = val;\n\n\t\t};\n\n\t\tthis.setDisPlayColumns = function( val ) {\n\n\t\t\tdisplay_columns = Global.convertColumnsTojGridFormat( val, layout_name );\n\t\t};\n\n\t\t//Only these columns can be shown no matter\n\t\tthis.setPossibleDisplayColumns = function( val, default_columns ) {\n\t\t\tpossible_display_columns = val;\n\n\t\t\tif ( default_columns ) {\n\t\t\t\tlist_view_default_columns = default_columns;\n\t\t\t} else {\n\t\t\t\tlist_view_default_columns = val;\n\t\t\t}\n\n\t\t\tif ( layout_name !== 'global_option_column' && //Simple options\n\t\t\t\tlayout_name !== 'global_tree_column' && //Tree Mode\n\t\t\t\tlayout_name !== 'global_sort_columns' &&\n\t\t\t\tlayout_name !== 'global_timesheet' &&\n\t\t\t\tlayout_name !== 'global_absence' ) {\n\t\t\t\tthis.initColumns();\n\t\t\t}\n\n\t\t};\n\n\t\tthis.setRowPerPage = function( val ) {\n\t\t\trow_per_page = val;\n\t\t};\n\n\t\tthis.setPagerData = function( val ) {\n\t\t\tpager_data = val;\n\t\t};\n\n\t\tthis.shouldInitColumns = function() {\n\t\t\tif ( layout_name === 'global_option_column' || //Simple options\n\t\t\t\tlayout_name === 'global_tree_column' || //Tree Mode\n\t\t\t\tlayout_name === 'global_sort_columns' ||\n\t\t\t\tlayout_name === 'global_timesheet' ||\n\t\t\t\tlayout_name === 'global_absence' ||\n\t\t\t\tlayout_name === 'global_simple_name' ||\n\t\t\t\tlayout_name === 'global_simple_name' + '_navigation' ) {\n\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t};\n\n\t\tthis.createItem = function( val, label ) {\n\t\t\tvar item = {};\n\n\t\t\titem[key] = val;\n\t\t\t$.each( display_columns, function( index, content ) {\n\n\t\t\t\tif ( key !== 'id' ) {\n\t\t\t\t\titem.id = 20000; //records id start from 10000\n\t\t\t\t}\n\t\t\t\titem[content.name] = label;\n\t\t\t\treturn false;\n\n\t\t\t} );\n\n\t\t\treturn item;\n\n\t\t};\n\n\t\tthis.initSourceData = function() {\n\t\t\tvar args = $this.buildUnSelectGridFilter();\n\t\t\tapi['get' + custom_key_name]( args, {\n\t\t\t\tonResult: function( result ) {\n\t\t\t\t\tvar result_data = result.getResult();\n\t\t\t\t\tif ( !Global.isArray( result_data ) ) {\n\t\t\t\t\t\tresult_data = [];\n\t\t\t\t\t}\n\t\t\t\t\tsource_data = result_data;\n\t\t\t\t\tpager_data = result.getPagerData();\n\n\t\t\t\t\t$this.trigger( 'initSourceComplete', [$this] );\n\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t//only do this once\n\t\t\tinit_data_immediately = false;\n\t\t};\n\n\t\tthis.addHideIdColumn = function( display_columns ) {\n\t\t\tvar id_column = { name: 'id', index: 'id', label: '', width: 0, hidden: true };\n\n\t\t\tdisplay_columns.push( id_column );\n\n\t\t\treturn display_columns;\n\t\t};\n\n\t\tvar buildSortBySelectColumns = function( array ) {\n\t\t\tvar sort_by_array = array;\n\t\t\tvar sort_by_select_columns = [];\n\t\t\tvar sort_by_unselect_columns = source_data;\n\n\t\t\tif ( sort_by_array ) {\n\t\t\t\t$.each( sort_by_array, function( index, content ) {\n\t\t\t\t\tfor ( var key in content ) {\n\t\t\t\t\t\tif ( key === 'label' || key === 'value' || key === 'fullValue' ) {\n\t\t\t\t\t\t\tsort_by_select_columns = sort_by_array;\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t$.each( sort_by_unselect_columns, function( index1, content1 ) {\n\t\t\t\t\t\t\tif ( content1.value === key ) {\n\t\t\t\t\t\t\t\tcontent1.sort = content[key];\n\t\t\t\t\t\t\t\tsort_by_select_columns.push( content1 );\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn sort_by_select_columns;\n\n\t\t};\n\n\t\t//For multiple items like .xxx could contains a few widgets.\n\t\tthis.each( function() {\n\t\t\tvar o = $.meta ? $.extend( {}, opts, $( this ).data() ) : opts;\n\t\t\tlabel_span = $( this ).find( '.a-combobox-label' );\n\t\t\tvar focus_input = $( this ).find( '.focus-input' );\n\n\t\t\tif ( o.always_include_columns ) {\n\t\t\t\talways_include_columns = o.always_include_columns;\n\t\t\t}\n\n\t\t\tif ( o.extendDataProcessWhenSearch ) {\n\t\t\t\textendDataProcessWhenSearch = o.extendDataProcessWhenSearch;\n\t\t\t}\n\n\t\t\tif ( o.always_search_full_columns ) {\n\t\t\t\talways_search_full_columns = o.always_search_full_columns;\n\t\t\t}\n\n\t\t\t//source_data id that add from outsite, used to set value before open awesomebox\n\t\t\tif ( o.added_items ) {\n\t\t\t\tadded_items = o.added_items;\n\t\t\t}\n\n\t\t\tif ( o.init_data_immediately ) {\n\t\t\t\tinit_data_immediately = o.init_data_immediately;\n\t\t\t}\n\n\t\t\t//first item label , like -- No Meal -- in Policy -> Schedule Policies\n\t\t\tif ( o.custom_first_label ) {\n\t\t\t\tcustom_first_label = o.custom_first_label;\n\t\t\t}\n\n\t\t\tif ( o.script_name ) {\n\t\t\t\tscript_name = o.script_name;\n\t\t\t}\n\n\t\t\tif ( o.get_real_data_on_multi ) {\n\t\t\t\tget_real_data_on_multi = o.get_real_data_on_multi;\n\t\t\t}\n\n\t\t\tif ( o.setRealValueCallBack ) {\n\t\t\t\tsetRealValueCallBack = o.setRealValueCallBack;\n\t\t\t}\n\n\t\t\tif ( o.navigation_mode ) {\n\t\t\t\tnavigation_mode = o.navigation_mode;\n\t\t\t\t$( this ).children().eq( 1 ).css( 'max-width', 132 );\n\t\t\t\t$( this ).children().eq( 1 ).css( 'min-width', 132 );\n\t\t\t}\n\n\t\t\tif ( o.search_panel_model ) {\n\t\t\t\t$( this ).children().eq( 1 ).css( 'max-width', 132 );\n\t\t\t\t$( this ).children().eq( 1 ).css( 'min-width', 132 );\n\t\t\t}\n\n\t\t\tif ( o.width ) {\n\t\t\t\t$( this ).children().eq( 1 ).css( 'max-width', o.width );\n\t\t\t\tif ( o.is_static_width ) {\n\t\t\t\t\t$( this ).children().eq( 1 ).css( 'min-width', o.width );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t$( this ).children().eq( 1 ).css( 'min-width', 132 );\n\t\t\t}\n\n\t\t\tif ( o.api_class ) {\n\t\t\t\tapi_class = o.api_class;\n\t\t\t\tapi = o.api_class;\n\t\t\t}\n\n\t\t\tif ( o.custom_key_name ) {\n\t\t\t\tcustom_key_name = o.custom_key_name;\n\t\t\t} else {\n\n\t\t\t\tif ( api ) {\n\t\t\t\t\tcustom_key_name = api.key_name;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( o.allow_multiple_selection ) {\n\t\t\t\tallow_multiple_selection = o.allow_multiple_selection;\n\t\t\t}\n\n\t\t\tif ( o.set_any ) {\n\t\t\t\tset_any = o.set_any;\n\t\t\t}\n\n\t\t\tif ( o.set_empty ) {\n\t\t\t\tset_empty = o.set_empty;\n\t\t\t}\n\n\t\t\tif ( o.set_special_empty ) {\n\t\t\t\tset_special_empty = o.set_special_empty;\n\t\t\t}\n\n\t\t\tif ( o.set_open ) {\n\t\t\t\tset_open = o.set_open;\n\t\t\t}\n\n\t\t\tif ( o.set_default ) {\n\t\t\t\tset_default = o.set_default;\n\t\t\t}\n\n\t\t\tif ( o.set_all ) {\n\t\t\t\tset_all = o.set_all;\n\t\t\t}\n\n\t\t\tif ( o.addition_source_function ) {\n\t\t\t\taddition_source_function = o.addition_source_function;\n\t\t\t}\n\n\t\t\tif ( o.column_option_key ) {\n\t\t\t\tcolumn_option_key = o.column_option_key;\n\t\t\t}\n\n\t\t\tfield = o.field;\n\n\t\t\tif ( o.validation_field ) {\n\t\t\t\tvalidation_field = o.validation_field;\n\t\t\t}\n\n\t\t\tif ( o.layout_name ) {\n\t\t\t\tif ( navigation_mode ) {\n\t\t\t\t\tlayout_name = o.layout_name + '_navigation';\n\t\t\t\t} else {\n\t\t\t\t\tlayout_name = o.layout_name;\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( o.hasOwnProperty( 'show_search_inputs' ) ) {\n\t\t\t\tshow_search_inputs = o.show_search_inputs;\n\t\t\t}\n\n\t\t\tif ( o.tree_mode ) {\n\t\t\t\ttree_mode = o.tree_mode;\n\t\t\t}\n\n\t\t\tif ( o.on_tree_grid_row_select ) {\n\t\t\t\ton_tree_grid_row_select = o.on_tree_grid_row_select;\n\t\t\t}\n\n\t\t\t//Always set this true;\n\t\t\tallow_drag_to_order = true;\n\n\t\t\tif ( o.key ) {\n\t\t\t\tkey = o.key;\n\t\t\t}\n\n\t\t\tif ( o.args ) {\n\t\t\t\t$this.args = o.args;\n\t\t\t}\n\n\t\t\tif ( o.customSearchFilter ) {\n\t\t\t\t$this.customSearchFilter = o.customSearchFilter;\n\t\t\t}\n\n\t\t\t//Set default args use when init source;\n\t\t\tif ( o.default_args ) {\n\t\t\t\t$this.setDefaultArgs( o.default_args );\n\t\t\t}\n\n\t\t\tvar $$this = this;\n\t\t\tfocus_input.unbind( 'keydown' ).bind( 'keydown', function( e ) {\n\t\t\t\t//Stop click event to top, prevent the body click event\n\t\t\t\tif ( e.keyCode === 13 || e.keyCode === 32 ) {\n\t\t\t\t\te.stopPropagation();\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tTTPromise.add( 'AComboBox', 'init' );\n\t\t\t\t\topenADropDown();\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tfocus_input.bind( 'focusin', function() {\n\t\t\t\t$( $$this ).addClass( 'focus' );\n\t\t\t} );\n\n\t\t\tfocus_input.bind( 'focusout', function() {\n\t\t\t\t$( $$this ).removeClass( 'focus' );\n\t\t\t} );\n\n\t\t\t$( this ).click( function( e ) {\n\t\t\t\te.stopPropagation();\n\t\t\t\tif ( !enabled ) {\n\t\t\t\t\tif ( LocalCacheData.current_open_sub_controller &&\n\t\t\t\t\t\tLocalCacheData.current_open_sub_controller.edit_view &&\n\t\t\t\t\t\tLocalCacheData.current_open_sub_controller.is_viewing ) {\n\t\t\t\t\t\terror_string = LocalCacheData.current_open_sub_controller.getViewModeErrorMessage();\n\t\t\t\t\t\t$this.showErrorTip( 10 );\n\t\t\t\t\t} else if ( LocalCacheData.current_open_primary_controller &&\n\t\t\t\t\t\tLocalCacheData.current_open_primary_controller.edit_view &&\n\t\t\t\t\t\tLocalCacheData.current_open_primary_controller.is_viewing ) {\n\t\t\t\t\t\terror_string = LocalCacheData.current_open_primary_controller.getViewModeErrorMessage();\n\t\t\t\t\t\t$this.showErrorTip( 10 );\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\tif ( dontOpen === true ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tTTPromise.add( 'AComboBox', 'init' );\n\t\t\t\t\topenADropDown();\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t$( this ).mouseover( function() {\n\t\t\t\tif ( enabled ) {\n\t\t\t\t\tif ( error_string && error_string.length > 0 ) {\n\t\t\t\t\t\t$this.showErrorTip( 1000 );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t$( this ).mouseout( function() {\n\t\t\t\t$this.hideErrorTip();\n\t\t\t} );\n\n\t\t\tif ( !o.width ) {\n\t\t\t\t$( this ).css( 'min-width', '169px' );\n\t\t\t} else {\n\t\t\t\t$( this ).css( 'min-width', ( o.width + 33 ) + 'px' );\n\t\t\t}\n\n\t\t\tif ( !$this.shouldInitColumns() ) { //Sort Selector in search panel\n\t\t\t\tdo_not_get_real_data = true; // For Simple OPTIONS mode\n\n\t\t\t}\n\n\t\t\tdisplay_columns = ALayoutCache.getDefaultColumn( layout_name ); //Get Default columns base on different layout name\n\t\t\tdisplay_columns = Global.convertColumnsTojGridFormat( display_columns, layout_name ); //Convert to jQgrid format\n\n\t\t\tif ( $this.shouldInitColumns() && !navigation_mode ) { //Sort Selector in search panel\n\n\t\t\t\t//init columnd when set possible columns for navigation mode\n\t\t\t\t$this.initColumns();\n\t\t\t}\n\n\t\t\tif ( o.id ) {\n\t\t\t\t$( this ).attr( 'id', o.id + '_AComboBox' );\n\t\t\t\tid = o.id;\n\t\t\t} else {\n\t\t\t\t$( this ).attr( 'id', field + '_AComboBox' );\n\t\t\t\tid = o.field;\n\t\t\t}\n\n\t\t\t$this.setEmptyLabel();\n\n\t\t\t//Open ADropDown\n\t\t\tfunction setADropDownSelectValues( select_items ) {\n\t\t\t\tif ( !( set_any && select_items == TTUUID.not_exist_id ) ) {\n\t\t\t\t\ta_dropdown.setSelectGridData( select_items );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction openADropDown() {\n\t\t\t\tif ( !enabled ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( LocalCacheData.openAwesomeBox ) {\n\t\t\t\t\tif ( LocalCacheData.openAwesomeBox.getId() === id ) {\n\t\t\t\t\t\tLocalCacheData.openAwesomeBox.onClose();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tLocalCacheData.openAwesomeBox.onClose();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tLocalCacheData.openAwesomeBox = $this;\n\n\t\t\t\t//Create and open ADropDown\n\t\t\t\ta_dropdown = Global.loadWidgetByName( FormItemType.AWESOME_DROPDOWN );\n\n\t\t\t\tvar display_show_all = false;\n\t\t\t\tif ( $this.shouldInitColumns() && !navigation_mode ) {\n\t\t\t\t\tdisplay_show_all = true;\n\t\t\t\t}\n\n\t\t\t\tif ( navigation_mode && default_args && default_args.filter_sort && !cached_sort_filter ) {\n\t\t\t\t\tcached_sort_filter = default_args.filter_sort;\n\t\t\t\t}\n\n\t\t\t\t//Create ADropDown\n\t\t\t\ta_dropdown = a_dropdown.ADropDown( {\n\t\t\t\t\tdisplay_show_all: display_show_all,\n\t\t\t\t\tallow_drag_to_order: allow_drag_to_order,\n\t\t\t\t\tallow_multiple_selection: allow_multiple_selection,\n\t\t\t\t\tshow_all: show_all,\n\t\t\t\t\tkey: key,\n\t\t\t\t\tid: id,\n\t\t\t\t\tcomboBox: $this,\n\t\t\t\t\tshow_search_inputs: show_search_inputs,\n\t\t\t\t\tsearch_input_filter: cached_search_inputs_filter,\n\t\t\t\t\tselect_grid_search_input_filter: cached_select_grid_search_inputs_filter,\n\t\t\t\t\tdefault_sort_filter: cached_sort_filter,\n\t\t\t\t\tdefault_select_grid_sort_filter: cached_selected_grid_sort_filter,\n\t\t\t\t\ttree_mode: tree_mode,\n\t\t\t\t\tcolumn_option_key: column_option_key,\n\t\t\t\t\tapi: api,\n\t\t\t\t\tdisplay_column_settings: $this.shouldInitColumns(),\n\n\t\t\t\t\ton_tree_grid_row_select: on_tree_grid_row_select\n\t\t\t\t} );\n\n\t\t\t\ta_dropdown_div = $( '' );\n\n\t\t\t\ta_dropdown_div.append( a_dropdown );\n\n\t\t\t\ta_dropdown_div.mouseenter( function() {\n\t\t\t\t\tis_mouse_over = true;\n\t\t\t\t} );\n\n\t\t\t\ta_dropdown_div.mouseleave( function() {\n\t\t\t\t\tis_mouse_over = false;\n\t\t\t\t} );\n\n\t\t\t\t$( 'body' ).append( a_dropdown_div );\n\n\t\t\t\tTTPromise.wait( 'AComboBox', 'init', function() {\n\t\t\t\t\ta_dropdown.setGridColumnsWidths();\n\n\t\t\t\t\t//Make sure we don't run this API call if the only selected value is a zero/not exists UUID,\n\t\t\t\t\t// otherwise it causes companies with thousands of employees to return *all* employees.\n\t\t\t\t\tif ( allow_multiple_selection == true && ( $this.getValue().length > 1 || ( $this.getValue().length == 1 && $this.getValue()[0] && ( $this.getValue()[0] != TTUUID.zero_id && $this.getValue()[0] != TTUUID.not_exist_id ) ) ) && api ) {\n\t\t\t\t\t\tvar args = {};\n\t\t\t\t\t\targs.filter_data = { id: $this.getValue() };\n\t\t\t\t\t\targs.filter_columns = $this.getColumnFilter();\n\t\t\t\t\t\targs.filter_items_per_page = 10000;\n\n\t\t\t\t\t\tapi['get' + custom_key_name]( args, {\n\t\t\t\t\t\t\tonResult: function( result ) {\n\t\t\t\t\t\t\t\tdoNext( result );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdoNext();\n\t\t\t\t\t}\n\n\t\t\t\t\tfunction doNext( result ) {\n\t\t\t\t\t\tif ( result ) {\n\t\t\t\t\t\t\ta_dropdown.setRealSelectItems( result.getResult(), $this.getValue() );\n\t\t\t\t\t\t}\n\t\t\t\t\t\ta_dropdown_div.css( 'opacity', '1' );\n\n\t\t\t\t\t\t//#2353 - remove the right side border from jqgrid.\n\t\t\t\t\t\tvar tables = $this.find( '.ui-jqgrid' ).find( 'table' );\n\t\t\t\t\t\tif ( tables.length > 0 ) {\n\t\t\t\t\t\t\tfor ( var i = 0; i < tables.length; i++ ) {\n\t\t\t\t\t\t\t\t//resize awesomebox grid tables to remove right-size gap.\n\t\t\t\t\t\t\t\tvar width = $( tables[0] ).parents( '.ui-jqgrid' ).find( '.ui-jqgrid-bdiv' ).width() - 11;\n\t\t\t\t\t\t\t\t$( tables[0] ).parents( '.ui-jqgrid' ).find( '.ui-jqgrid-view' ).width( width );\n\t\t\t\t\t\t\t\t$( tables[i] ).width( width );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ta_dropdown.setUnSelectGridDragAble();\n\t\t\t\t\t\ta_dropdown.setSelectGridDragAble();\n\t\t\t\t\t}\n\n\t\t\t\t} );\n\n\t\t\t\ta_dropdown.bind( 'close', $this.onClose );\n\n\t\t\t\tvar layout = ALayoutCache.layout_dic[layout_name];\n\n\t\t\t\t//Always use columns from global cache if columns is not default\n\t\t\t\tif ( layout_name && layout && Global.isSet( layout.data ) ) {\n\n\t\t\t\t\tvar current_display_columns = layout.data.display_columns;\n\n\t\t\t\t\t//Happen when save no columns in column setting for navigation mode\n\t\t\t\t\tif ( current_display_columns.length > 0 ) {\n\t\t\t\t\t\t//Only check possible columns if any\n\t\t\t\t\t\tif ( possible_display_columns ) {\n\t\t\t\t\t\t\tcurrent_display_columns = filterBaseOnPossibleColumns( current_display_columns );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tif ( list_view_default_columns ) {\n\t\t\t\t\t\t\tcurrent_display_columns = list_view_default_columns;\n\t\t\t\t\t\t\tcurrent_display_columns = filterBaseOnPossibleColumns( current_display_columns );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrent_display_columns = Global.convertColumnsTojGridFormat( current_display_columns, layout_name );\n\n\t\t\t\t\tvar current_row_per_page = layout.data.row_per_page;\n\n\t\t\t\t\t//If current columns or row_per_page not same as saved layout. Reload data base on current setting\n\t\t\t\t\tif ( $this.checkIfLayoutChanged( current_display_columns ) || ( row_per_page !== current_row_per_page && !navigation_mode ) ) {\n\n\t\t\t\t\t\tdisplay_columns = current_display_columns;\n\t\t\t\t\t\tsource_data = null;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( !navigation_mode ) {\n\t\t\t\t\t\trow_per_page = current_row_per_page;\n\n\t\t\t\t\t\tif ( !set_default_args_manually ) {\n\t\t\t\t\t\t\tif ( Global.isSet( layout.data.type ) && layout.data.type === 10 ) {\n\t\t\t\t\t\t\t\tvar default_args = {};\n\t\t\t\t\t\t\t\tdefault_args.filter_data = layout.data.filter_data;\n\t\t\t\t\t\t\t\tdefault_args.filter_sort = layout.data.filter_sort;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdefault_args = null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\t//Set columns first\n\t\t\t\ta_dropdown.setColumns( display_columns );\n\n\t\t\t\t//Set DropDown position\n\t\t\t\t//use default with since .width() not return correct width when first open\n\n\t\t\t\tvar dropdown_width = a_dropdown.getBoxWidth();\n\n\t\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\t\tdropdown_width = dropdown_width * 2 + 30 + 15;\n\t\t\t\t}\n\n\t\t\t\tif ( ( dropdown_width + $( $this ).offset().left + 50 ) > Global.bodyWidth() ) {\n\t\t\t\t\ta_dropdown_div.css( 'left', ( Global.bodyWidth() - dropdown_width - 50 ) );\n\t\t\t\t} else {\n\t\t\t\t\ta_dropdown_div.css( 'left', $( $this ).offset().left );\n\t\t\t\t}\n\n\t\t\t\t// makes sure it shown on the screen, will calculte position after source setting\n\t\t\t\tif ( ( $( $this ).offset().top + 25 + 275 ) < Global.bodyHeight() ) {\n\t\t\t\t\ta_dropdown_div.css( 'top', ( $( $this ).offset().top + 25 ) );\n\t\t\t\t} else {\n\t\t\t\t\ta_dropdown_div.css( 'top', ( $( $this ).offset().top - 275 ) );\n\t\t\t\t}\n\n\t\t\t\t// This will never change when search in search input. Set it back to dropdown every time when open\n\t\t\t\tif ( !source_data ) {\n\t\t\t\t\t//When using pagination and first opening the dropdown box, we need to exclude the selected items from the API call\n\t\t\t\t\t// so the first page will always be populated with a full page of records.\n\t\t\t\t\t// Lower down we make a separate API call to get the records for the selected items, and source_data.concat() them there.\n\t\t\t\t\tvar args = $this.buildUnSelectGridFilter( $this.getValue() );\n\n\t\t\t\t\t//Error: TypeError: api is null in /interface/html5/global/widgets/awesomebox/AComboBox.js?v=8.0.0-20141117-112033 line 2364\n\t\t\t\t\tif ( !api ) {\n\t\t\t\t\t\tif ( addition_source_function ) { //Required to add data to search UI for custom fields\n\t\t\t\t\t\t\tsource_data = addition_source_function( $this, source_data );\n\t\t\t\t\t\t\ta_dropdown.setUnselectedGridData( source_data );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tTTPromise.resolve( 'AComboBox', 'init' );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tapi['get' + custom_key_name]( args, {\n\t\t\t\t\t\tonResult: function( result ) {\n\t\t\t\t\t\t\tvar result_data = result.getResult();\n\n\t\t\t\t\t\t\tif ( !Global.isArray( result_data ) ) {\n\t\t\t\t\t\t\t\tresult_data = [];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tsource_data = result_data;\n\n\t\t\t\t\t\t\t//set this outside, to add more data to source_data\n\t\t\t\t\t\t\tif ( addition_source_function ) {\n\t\t\t\t\t\t\t\tsource_data = addition_source_function( $this, source_data );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tnavigation_mode_source_data_before_open = null;\n\n\t\t\t\t\t\t\tif ( Global.isSet( api ) ) {\n\t\t\t\t\t\t\t\tsource_data = Global.formatGridData( source_data, api.key_name );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\t\t\t\t\tif ( set_all ) {\n\t\t\t\t\t\t\t\t\t$this.createFirstItem();\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// For select items which only contains ids, like all awesomeboxes in edit view\n\t\t\t\t\t\t\t\t// Similar code is also below in the } else { clause of this IF statement.\n\t\t\t\t\t\t\t\tif ( get_real_data_when_open ) {\n\t\t\t\t\t\t\t\t\tget_real_data_when_open = false;\n\n\t\t\t\t\t\t\t\t\ta_dropdown.setUnselectedGridData( source_data );\n\n\t\t\t\t\t\t\t\t\tif ( !select_items || ( select_items && select_items.length == 1 && ( select_items[0] == TTUUID.zero_id || select_items[0] == TTUUID.not_exist_id ) ) ) {\n\t\t\t\t\t\t\t\t\t\tTTPromise.resolve( 'AComboBox', 'init' );\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tvar args = {};\n\t\t\t\t\t\t\t\t\t\targs.filter_data = { id: select_items };\n\t\t\t\t\t\t\t\t\t\targs.filter_columns = $this.getColumnFilter();\n\t\t\t\t\t\t\t\t\t\targs.filter_items_per_page = 10000;\n\n\t\t\t\t\t\t\t\t\t\t//Error: TypeError: null is not an object (evaluating 'select_items.length') in /interface/html5/global/widgets/awesomebox/AComboBox.js?v=8.0.0-20141230-113526 line 2441\n\t\t\t\t\t\t\t\t\t\t//if select items contains data like 0, for example Employee in Recurring Schedule edit view\n\t\t\t\t\t\t\t\t\t\tvar local_data = false;\n\t\t\t\t\t\t\t\t\t\tif ( select_items && select_items.length > 0 && ( select_items[0] == TTUUID.zero_id || select_items[0] == TTUUID.not_exist_id ) ) {\n\t\t\t\t\t\t\t\t\t\t\tlocal_data = $this.getLocalSelectItem( select_items[0] );\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tapi['get' + custom_key_name]( args, {\n\t\t\t\t\t\t\t\t\t\t\tonResult: function( result ) {\n\t\t\t\t\t\t\t\t\t\t\t\tselect_items = result.getResult();\n\n\t\t\t\t\t\t\t\t\t\t\t\t//Since the initial API call above excluded the selected items, we need to concat() them back onto the source_data array\n\t\t\t\t\t\t\t\t\t\t\t\tsource_data = source_data.concat( select_items ); //Do above the unshift( local_data ) below.\n\n\t\t\t\t\t\t\t\t\t\t\t\tif ( local_data ) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tselect_items.unshift( local_data );\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\t//a_dropdown.setSelectGridData( select_items ); //set Selected Data after set sourceData\n\t\t\t\t\t\t\t\t\t\t\t\tsetADropDownSelectValues( select_items );\n\t\t\t\t\t\t\t\t\t\t\t\tTTPromise.resolve( 'AComboBox', 'init' );\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\ta_dropdown.setUnselectedGridData( source_data );\n\t\t\t\t\t\t\t\t\t//Issue #3220 - When an AwesomeBox has only 1 item selected on initial load, that item will disappear on reopen\n\t\t\t\t\t\t\t\t\t//if it is unselected by the user as it is not in the source_data for the AwesomeBox.\n\t\t\t\t\t\t\t\t\t//Since the initial API call above excluded the selected items, we need to concat() them back onto the source_data array\n\t\t\t\t\t\t\t\t\tif ( Array.isArray( select_items ) && select_items.length > 0 && select_items[0].id ) {\n\t\t\t\t\t\t\t\t\t\tsource_data = source_data.concat( select_items );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetADropDownSelectValues( select_items );\n\t\t\t\t\t\t\t\t\tTTPromise.resolve( 'AComboBox', 'init' );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif ( set_empty || set_any || set_default || set_open || set_special_empty ) {\n\t\t\t\t\t\t\t\t\t$this.createFirstItem();\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\ta_dropdown.setUnselectedGridData( source_data );\n\t\t\t\t\t\t\t\ta_dropdown.setSelectItem( select_item );\n\t\t\t\t\t\t\t\tTTPromise.resolve( 'AComboBox', 'init' );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tpager_data = result.getPagerData();\n\t\t\t\t\t\t\ta_dropdown.setPagerData( pager_data );\n\n\t\t\t\t\t\t\tif ( !Global.isEmpty( cached_search_inputs_filter ) || !Global.isEmpty( cached_sort_filter ) ) {\n\t\t\t\t\t\t\t\ta_dropdown.getUnSelectGrid().grid.hide();\n\t\t\t\t\t\t\t\t$this.onADropDownSearch( 'unselect_grid' );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( !Global.isEmpty( cached_select_grid_search_inputs_filter ) || !Global.isEmpty( cached_selected_grid_sort_filter ) ) {\n\t\t\t\t\t\t\t\ta_dropdown.getSelectGrid().grid.hide();\n\t\t\t\t\t\t\t\t$this.onADropDownSearch( 'select_grid' );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t} else { //Use cache if already loaded data before\n\n\t\t\t\t\tif ( Global.isSet( api ) ) {\n\t\t\t\t\t\tsource_data = Global.formatGridData( source_data, api.key_name );\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\t\t\tif ( layout_name === 'global_sort_columns' ) {\n\t\t\t\t\t\t\tselect_items = buildSortBySelectColumns( select_items );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Similar code is also below in the above TRUE IF statement clause.\n\t\t\t\t\t\tif ( get_real_data_when_open ) {\n\t\t\t\t\t\t\tget_real_data_when_open = false;\n\n\t\t\t\t\t\t\ta_dropdown.setUnselectedGridData( source_data );\n\n\t\t\t\t\t\t\tif ( !select_items || ( select_items && select_items.length == 1 && ( select_items[0] == TTUUID.zero_id || select_items[0] == TTUUID.not_exist_id ) ) ) {\n\t\t\t\t\t\t\t\tTTPromise.resolve( 'AComboBox', 'init' );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tvar args = {};\n\t\t\t\t\t\t\t\targs.filter_data = { id: select_items };\n\t\t\t\t\t\t\t\targs.filter_columns = $this.getColumnFilter();\n\t\t\t\t\t\t\t\targs.filter_items_per_page = 10000;\n\n\t\t\t\t\t\t\t\t//Error: TypeError: null is not an object (evaluating 'select_items.length') in /interface/html5/global/widgets/awesomebox/AComboBox.js?v=8.0.0-20141230-113526 line 2441\n\t\t\t\t\t\t\t\t//if select items contains data like 0, for example Employee in Recurring Schedule edit view\n\t\t\t\t\t\t\t\tvar local_data = false;\n\t\t\t\t\t\t\t\tif ( select_items && select_items.length > 0 && ( select_items[0] == TTUUID.zero_id || select_items[0] == TTUUID.not_exist_id ) ) {\n\t\t\t\t\t\t\t\t\tlocal_data = $this.getLocalSelectItem( select_items[0] );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tapi['get' + custom_key_name]( args, {\n\t\t\t\t\t\t\t\t\tonResult: function( result ) {\n\t\t\t\t\t\t\t\t\t\tselect_items = result.getResult();\n\n\t\t\t\t\t\t\t\t\t\tif ( local_data ) {\n\t\t\t\t\t\t\t\t\t\t\tselect_items.unshift( local_data );\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\ta_dropdown.setUnselectedGridData( source_data );\n\t\t\t\t\t\t\t\t\t\t//a_dropdown.setSelectGridData( select_items ); //set Selected Data after set sourceData\n\t\t\t\t\t\t\t\t\t\tsetADropDownSelectValues( select_items );\n\t\t\t\t\t\t\t\t\t\tTTPromise.resolve( 'AComboBox', 'init' );\n\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ta_dropdown.setUnselectedGridData( source_data );\n\t\t\t\t\t\t\t//a_dropdown.setSelectGridData( select_items );\n\t\t\t\t\t\t\tsetADropDownSelectValues( select_items );\n\t\t\t\t\t\t\tTTPromise.resolve( 'AComboBox', 'init' );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\ta_dropdown.setUnselectedGridData( source_data );\n\t\t\t\t\t\ta_dropdown.setSelectItem( select_item );\n\t\t\t\t\t\tTTPromise.resolve( 'AComboBox', 'init' );\n\t\t\t\t\t}\n\n\t\t\t\t\ta_dropdown.setPagerData( pager_data );\n\n\t\t\t\t\tif ( !Global.isEmpty( cached_search_inputs_filter ) || !Global.isEmpty( cached_sort_filter ) ) {\n\t\t\t\t\t\ta_dropdown.getUnSelectGrid().grid.hide();\n\t\t\t\t\t\t$this.onADropDownSearch( 'unselect_grid' );\n\t\t\t\t\t\tcurrent_open_page = 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif ( current_open_page > 1 && current_open_page <= pager_data.last_page_number ) {\n\t\t\t\t\t\t\ta_dropdown.getUnSelectGrid().grid.hide();\n\t\t\t\t\t\t\t$this.onADropDownSearch( 'unselect_grid', current_open_page );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( !Global.isEmpty( cached_select_grid_search_inputs_filter ) || !Global.isEmpty( cached_selected_grid_sort_filter ) ) {\n\t\t\t\t\t\t//a_dropdown.getSelectGrid().grid.hide(); //#2721 - This helps fixes a bug where if you expand a awesomebox (ie: Edit Policy Group, Absence Policys), on right-hand side click clear search. Click Move All on right-hand side. Collapse, expand, click move All left-hand side. Both sides are now blank because the right grid had a display: none attached to it.\n\t\t\t\t\t\t$this.onADropDownSearch( 'select_grid' );\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t\treturn this;\n\n\t};\n\n\t$.fn.AComboBox.defaults = {};\n\t$.fn.AComboBox.html_template = `\n\t