1 line
260 KiB
JavaScript
1 line
260 KiB
JavaScript
(self.webpackChunktimetrex=self.webpackChunktimetrex||[]).push([["awesomebox-ADropDown"],{3234:(__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.ADropDown = function( options ) {\n\t\tvar opts = $.extend( {}, $.fn.ADropDown.defaults, options );\n\n\t\tvar unselect_grid = null;\n\n\t\tvar select_grid = null;\n\n\t\tvar total_display_span = null;\n\n\t\tvar static_source_data = null; //Always use this to help to set Select data\n\n\t\tvar id = null;\n\n\t\tvar key = 'id';\n\n\t\tvar parent_a_combo_box = null;\n\n\t\tvar a_dropdown_this = this;\n\n\t\tvar unselect_grid_header_array = [];\n\n\t\tvar select_grid_header_array = [];\n\n\t\tvar show_search_inputs = true;\n\n\t\tvar local_search_mode = false;\n\n\t\tvar local_search_optional_filter = [];\n\n\t\tvar unselect_grid_search_map = null;\n\n\t\tvar select_grid_search_map = null;\n\n\t\tvar unselect_grid_sort_map = null;\n\n\t\tvar select_grid_sort_map = null;\n\n\t\tvar select_item = null;\n\n\t\tvar tree_mode = false;\n\n\t\tvar on_tree_grid_row_select = false; //#2566 - added select row callback so that trees can be used for edit-view navigation\n\n\t\tvar unselect_grid_last_row = '';\n\n\t\tvar select_grid_last_row = '';\n\n\t\tvar allow_multiple_selection = true;\n\n\t\tvar allow_drag_to_order = false;\n\n\t\tvar pager_data = null;\n\n\t\tvar paging_widget = null;\n\n\t\tvar real_selected_items = null; //Set this after search in select grid;\n\n\t\tvar start;\n\n\t\tvar last;\n\n\t\tvar next;\n\n\t\tvar end;\n\n\t\tvar paging_selector;\n\n\t\tvar left_buttons_div;\n\n\t\tvar right_buttons_div;\n\n\t\tvar left_buttons_enable;\n\n\t\tvar right_buttons_enable;\n\n\t\tvar field;\n\n\t\tvar error_tip_box;\n\n\t\tvar error_string = '';\n\n\t\tvar default_height = 150;\n\n\t\tvar unselect_grid_no_result_box = null;\n\n\t\tvar select_grid_no_result_box = null;\n\n\t\tvar box_width;\n\n\t\tvar focus_in_select_grid = false;\n\n\t\tvar auto_sort = false;\n\n\t\tvar isChanged = false;\n\n\t\tvar api = null; //Pass from owner\n\n\t\tvar column_editor = null;\n\n\t\tvar column_option_key = null;\n\n\t\tvar display_column_settings = true;\n\n\t\tvar quick_search_timer;\n\n\t\tvar quick_search_typed_keys = '';\n\n\t\tvar quick_search_dic = {};\n\n\t\tvar max_height = false;\n\t\tvar static_height = false;\n\n\t\tvar resize_grids = false;\n\n\t\t//Select all records in target grid\n\t\tvar selectAllInGrid = function( target, deSelect ) {\n\t\t\ttarget.resetSelection();\n\t\t\tif ( !deSelect ) {\n\t\t\t\tvar source_data = target.getGridParam( 'data' );\n\t\t\t\tvar len = source_data.length;\n\t\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\t\tvar item = source_data[i];\n\t\t\t\t\tif ( item.hidden ) {\n continue;\n }\n\t\t\t\t\tif ( Global.isSet( item.id ) ) {\n\t\t\t\t\t\ttarget.grid.jqGrid( 'setSelection', item.id, false );\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttarget.grid.jqGrid( 'setSelection', i + 1, false );\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\ttarget.grid.parents( '.cbox-header' ).prop( 'checked', true );\n\t\t\t}\n\t\t};\n\n\t\tGlobal.addCss( 'global/widgets/awesomebox/ADropDown.css' );\n\n\t\tthis.isLocalSearchMode = function() {\n return local_search_mode;\n };\n\n\t\tthis.setLocalSearchMode = function( value ) {\n local_search_mode = value;\n };\n\n\t\tthis.isChanged = function() {\n\t\t\treturn isChanged;\n\t\t};\n\n\t\tthis.setIsChanged = function( val ) {\n\t\t\tisChanged = val;\n\t\t};\n\n\t\tthis.unSelectAll = function( target ) {\n\t\t\tselectAllInGrid( target, true );\n\t\t};\n\n\t\tthis.getFocusInSeletGrid = function() {\n\t\t\treturn focus_in_select_grid;\n\t\t};\n\n\t\tthis.selectAll = function() {\n\n\t\t\tif ( focus_in_select_grid ) {\n\t\t\t\tselectAllInGrid( select_grid );\n\t\t\t} else {\n\t\t\t\tselectAllInGrid( unselect_grid );\n\t\t\t}\n\n\t\t};\n\n\t\tthis.gridScrollTop = function() {\n\n\t\t\tunselect_grid.grid.parent().parent().scrollTop( 0 );\n\t\t};\n\n\t\tthis.gridScrollDown = function() {\n\n\t\t\tunselect_grid.grid.parent().parent().scrollTop( 10000 );\n\t\t};\n\n\t\tthis.getBoxWidth = function() {\n\t\t\treturn box_width;\n\t\t};\n\n\t\tthis.setErrorStyle = function( errStr, show, isWarning ) {\n\t\t\tif ( isWarning ) {\n\t\t\t\t$( this ).addClass( 'warning-tip' );\n\t\t\t} else {\n\t\t\t\t$( this ).addClass( '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( '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( 'error-tip' );\n\t\t\t$( this ).removeClass( 'warning-tip' );\n\t\t\tthis.hideErrorTip();\n\t\t\terror_string = '';\n\t\t};\n\n\t\tthis.getField = function() {\n\t\t\treturn field;\n\t\t};\n\n\t\t// Must call after setUnSelectGridData\n\t\tthis.setValue = function( val ) {\n\t\t\tthis.setSelectGridData( val );\n\t\t};\n\n\t\tthis.getValue = function() {\n\t\t\treturn this.getSelectItems();\n\t\t};\n\n\t\tthis.getSelectGridSortMap = function() {\n\t\t\treturn select_grid_sort_map;\n\t\t};\n\n\t\tthis.getUnSelectGridSortMap = function() {\n\t\t\treturn unselect_grid_sort_map;\n\t\t};\n\n\t\tthis.getUnSelectGridMap = function() {\n\n\t\t\tif ( !unselect_grid_search_map ) {\n\t\t\t\tunselect_grid_search_map = {};\n\t\t\t}\n\n\t\t\treturn unselect_grid_search_map;\n\t\t};\n\n\t\tthis.getUnSelectGrid = function() {\n\t\t\treturn unselect_grid;\n\t\t};\n\n\t\tthis.getSelectGrid = function() {\n\t\t\treturn select_grid;\n\t\t};\n\n\t\tthis.getSelectGridMap = function() {\n\n\t\t\tif ( !select_grid_search_map ) {\n\t\t\t\tselect_grid_search_map = {};\n\t\t\t}\n\n\t\t\tvar ids = [];\n\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\tvar select_items = a_dropdown_this.getSelectItems();\n\t\t\t\tfor ( var i = 0; i < select_items.length; i++ ) {\n\t\t\t\t\tids.push( select_items[i][key] );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ids.length > 0 ) {\n\t\t\t\tselect_grid_search_map.id = ids;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn select_grid_search_map;\n\t\t};\n\n\t\tthis.collectUnselectGridColumns = function() {\n\t\t\tvar columns = unselect_grid.getGridParam( 'colModel' );\n\n\t\t\tvar len = ( ( columns ) ? columns.length : 0 );\n\n\t\t\tunselect_grid_header_array = [];\n\n\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\tvar column_info = columns[i];\n\t\t\t\tvar column_header = $( this ).find( 'div #jqgh_unselect_grid_' + id + '_' + column_info.name );\n\n\t\t\t\tunselect_grid_header_array.push( column_header.TGridHeader( { column_model: column_info } ) );\n\n\t\t\t\tcolumn_header.bind( 'headerClick', onUnSelectColumnHeaderClick );\n\t\t\t}\n\n\t\t\ta_dropdown_this.setGridHeaderStyle( 'unselect_grid' );\n\n\t\t\tfunction onUnSelectColumnHeaderClick( e, headerE, column_model ) {\n\n\t\t\t\t//Error: Uncaught TypeError: Cannot read property 'setCachedSortFilter' of null in /interface/html5/global/widgets/awesomebox/ADropDown.js?v=7.4.6-20141027-072624 line 286\n\t\t\t\tif ( !parent_a_combo_box || !parent_a_combo_box.getAPI() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvar field = column_model.name;\n\n\t\t\t\tif ( field === 'cb' ) { //first column, check box column.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( headerE.metaKey || headerE.ctrlKey ) {\n\t\t\t\t\ta_dropdown_this.buildSortCondition( false, field, 'unselect_grid' );\n\t\t\t\t} else {\n\t\t\t\t\ta_dropdown_this.buildSortCondition( true, field, 'unselect_grid' );\n\n\t\t\t\t}\n\n\t\t\t\tparent_a_combo_box.setCachedSortFilter( unselect_grid_sort_map );\n\t\t\t\ta_dropdown_this.setGridHeaderStyle( 'unselect_grid' );\n\t\t\t\tparent_a_combo_box.onADropDownSearch( 'unselect_grid' );\n\n\t\t\t}\n\t\t};\n\n\t\tthis.buildSortCondition = function( reset, field, targetName ) {\n\n\t\t\tvar sort_map = null;\n\t\t\tvar nextSort = 'desc';\n\n\t\t\tif ( targetName === 'unselect_grid' ) {\n\t\t\t\tsort_map = unselect_grid_sort_map;\n\t\t\t} else {\n\t\t\t\tsort_map = select_grid_sort_map;\n\t\t\t}\n\n\t\t\tif ( reset ) {\n\n\t\t\t\tif ( sort_map && sort_map.length > 0 ) {\n\t\t\t\t\tvar len = sort_map.length;\n\t\t\t\t\tvar found = false;\n\t\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\t\tvar sortItem = sort_map[i];\n\t\t\t\t\t\tfor ( var key in sortItem ) {\n\t\t\t\t\t\t\tif ( key === field ) {\n\t\t\t\t\t\t\t\tif ( sortItem[key] === 'asc' ) {\n\t\t\t\t\t\t\t\t\tnextSort = 'desc';\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tnextSort = 'asc';\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( found ) {\n\t\t\t\t\t\t\tbreak;\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\tsort_map = [\n\t\t\t\t\t{}\n\t\t\t\t];\n\t\t\t\tsort_map[0][field] = nextSort;\n\n\t\t\t} else {\n\t\t\t\tif ( !sort_map ) {\n\t\t\t\t\tsort_map = [\n\t\t\t\t\t\t{}\n\t\t\t\t\t];\n\t\t\t\t\tsort_map[0][field] = 'desc';\n\t\t\t\t} else {\n\t\t\t\t\tlen = sort_map.length;\n\t\t\t\t\tfound = false;\n\t\t\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\t\t\tsortItem = sort_map[i];\n\t\t\t\t\t\tfor ( var key in sortItem ) {\n\t\t\t\t\t\t\tif ( key === field ) {\n\t\t\t\t\t\t\t\tif ( sortItem[key] === 'asc' ) {\n\t\t\t\t\t\t\t\t\tsortItem[key] = 'desc';\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsortItem[key] = 'asc';\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( found ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( !found ) {\n\t\t\t\t\t\tsort_map.push( {} );\n\t\t\t\t\t\tsort_map[len][field] = 'desc';\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( targetName === 'unselect_grid' ) {\n\t\t\t\tunselect_grid_sort_map = sort_map;\n\t\t\t} else {\n\t\t\t\tselect_grid_sort_map = sort_map;\n\t\t\t}\n\n\t\t};\n\n\t\tthis.setGridHeaderStyle = function( targetName ) {\n\n\t\t\tvar headerArray = [];\n\t\t\tvar sort_map = [];\n\n\t\t\tif ( targetName === 'unselect_grid' ) {\n\t\t\t\theaderArray = unselect_grid_header_array;\n\t\t\t\tsort_map = unselect_grid_sort_map;\n\t\t\t} else {\n\t\t\t\theaderArray = select_grid_header_array;\n\t\t\t\tsort_map = select_grid_sort_map;\n\t\t\t}\n\n\t\t\tvar len = headerArray.length;\n\n\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\tvar tGridHeader = headerArray[i];\n\t\t\t\tvar field = tGridHeader.getColumnModel().name;\n\n\t\t\t\ttGridHeader.cleanSortStyle();\n\n\t\t\t\tif ( sort_map ) {\n\t\t\t\t\tvar sortArrayLen = sort_map.length;\n\n\t\t\t\t\tfor ( var j = 0; j < sortArrayLen; j++ ) {\n\t\t\t\t\t\tvar sortItem = sort_map[j];\n\t\t\t\t\t\tvar sortField = Global.getFirstKeyFromObject( sortItem );\n\t\t\t\t\t\tif ( sortField === field ) {\n\n\t\t\t\t\t\t\tif ( sortArrayLen > 1 ) {\n\t\t\t\t\t\t\t\ttGridHeader.setSortStyle( sortItem[sortField], j + 1 );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\ttGridHeader.setSortStyle( sortItem[sortField], 0 );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\t\tthis.collectSelectGridColumns = function() {\n\t\t\tvar columns = select_grid.getGridParam( 'colModel' );\n\n\t\t\tvar len = ( ( columns ) ? columns.length : 0 );\n\n\t\t\tselect_grid_header_array = [];\n\n\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\tvar column_info = columns[i];\n\t\t\t\tvar column_header = $( this ).find( 'div #jqgh_select_grid_' + id + '_' + column_info.name );\n\n\t\t\t\tselect_grid_header_array.push( column_header.TGridHeader( { column_model: column_info } ) );\n\n\t\t\t\tcolumn_header.bind( 'headerClick', onSelectColumnHeaderClick );\n\n\t\t\t}\n\t\t\ta_dropdown_this.setGridHeaderStyle( 'select_grid' );\n\n\t\t\tfunction onSelectColumnHeaderClick( e, headerE, column_model ) {\n\n\t\t\t\tif ( !parent_a_combo_box || !parent_a_combo_box.getAPI() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvar field = column_model.name;\n\n\t\t\t\tif ( field === 'cb' ) { //first column, check box column.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( headerE.metaKey || headerE.ctrlKey ) {\n\t\t\t\t\ta_dropdown_this.buildSortCondition( false, field, 'select_grid' );\n\t\t\t\t} else {\n\t\t\t\t\ta_dropdown_this.buildSortCondition( true, field, 'select_grid' );\n\n\t\t\t\t}\n\t\t\t\tparent_a_combo_box.setCachedSelectedGridSortFilter( select_grid_sort_map );\n\t\t\t\ta_dropdown_this.setGridHeaderStyle( 'select_grid' );\n\t\t\t\tparent_a_combo_box.onADropDownSearch( 'select_grid' );\n\n\t\t\t}\n\n\t\t};\n\n\t\t//HightLight select item in UnSelect grid when !allow_multiple_selection\n\t\tthis.setSelectItem = function( val, target_grid ) {\n\t\t\tif ( !target_grid ) {\n\t\t\t\ttarget_grid = unselect_grid;\n\t\t\t}\n\t\t\tvar source_data = target_grid.getGridParam( 'data' );\n\t\t\tval && ( select_item = val );\n\t\t\tif ( source_data && source_data.length > 0 ) {\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\tvar temp_val = val;\n\t\t\t\t\t!val && ( temp_val = source_data[0] );\n\n\t\t\t\t\tvar content_key = key;\n\t\t\t\t\tif ( tree_mode && key == 'id' ) {\n\t\t\t\t\t\tcontent_key = '_id_';\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( content[content_key] == temp_val[key] ) { //Some times 0, sometimes '0'\n\n\t\t\t\t\t\tvar content_id_key = 'id';\n\t\t\t\t\t\tif ( tree_mode ) {\n\t\t\t\t\t\t\tcontent_id_key = '_id_';\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t//Always use id to set select row, all record array should have id\n\t\t\t\t\t\ttarget_grid.grid.find( 'tr[id=\"' + content[content_id_key] + '\"]' ).focus();\n\t\t\t\t\t\tif ( target_grid.grid.hasClass( 'unselect-grid' ) ) {\n\t\t\t\t\t\t\tif ( unselect_grid_last_row ) {\n\t\t\t\t\t\t\t\ttarget_grid.grid.jqGrid( 'saveRow', unselect_grid_last_row );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tunselect_grid_last_row = content[content_id_key];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif ( select_grid_last_row ) {\n\t\t\t\t\t\t\t\ttarget_grid.grid.jqGrid( 'saveRow', select_grid_last_row );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tselect_grid_last_row = content[content_id_key];\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttarget_grid.grid.jqGrid( 'setSelection', content[content_id_key], false );\n\t\t\t\t\t\ttarget_grid.grid.jqGrid( 'editRow', content[content_id_key], true );\n\t\t\t\t\t\tval && ( select_item = content );\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.setTotalDisplaySpan();\n\t\t\t}\n\t\t};\n\n\t\tthis.getUnSelectGridData = function() {\n\t\t\treturn unselect_grid.getGridParam( 'data' );\n\t\t};\n\n\t\tthis.getSelectItem = function() {\n\t\t\treturn select_item;\n\t\t};\n\n\t\tthis.getSelectItems = function() {\n\t\t\t//Save last edit row if there is editable row in grid cell;\n\t\t\tif ( unselect_grid_last_row.length > 0 ) {\n\t\t\t\tunselect_grid.grid.jqGrid( 'saveRow', unselect_grid_last_row );\n\t\t\t\tunselect_grid_last_row = '';\n\t\t\t}\n\n\t\t\tif ( select_grid_last_row.length > 0 ) {\n\t\t\t\tselect_grid.grid.jqGrid( 'saveRow', select_grid_last_row );\n\t\t\t\tselect_grid_last_row = '';\n\t\t\t}\n\n\t\t\tvar retval = null;\n\t\t\tif ( show_search_inputs && real_selected_items && real_selected_items.length > 0 ) {\n\t\t\t\tretval = real_selected_items;\n\t\t\t} else {\n\t\t\t\tretval = select_grid.getGridParam( 'data' ); //Set this when setSelectGridItems\n\t\t\t}\n\n\t\t\t//Make sure we never return null, and always at least an empty array. This helps prevent JS excptions when we run .length on the return value.\n\t\t\tif ( Global.isArray( retval ) == false ) {\n\t\t\t\treturn Array();\n\t\t\t}\n\n\t\t\treturn retval;\n\t\t};\n\n\t\tthis.setRealSelectItems = function( all_records, selected_ids ) {\n\t\t\treal_selected_items = [];\n\t\t\tif ( selected_ids != TTUUID.zero_id && selected_ids.length > 0 ) {\n\t\t\t\tfor ( var n = 0; n < all_records.length; n++ ) {\n\t\t\t\t\tif ( selected_ids.indexOf( all_records[n].id ) != -1 ) {\n\t\t\t\t\t\treal_selected_items.push( all_records[n] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn real_selected_items;\n\t\t};\n\n\t\tthis.getAllowMultipleSelection = function() {\n\t\t\treturn allow_multiple_selection;\n\t\t};\n\n\t\tthis.getResizeGrids = function() {\n\t\t\treturn resize_grids;\n\t\t};\n\n\t\tthis.setResizeGrids = function( val ) {\n\t\t\tresize_grids = val;\n\t\t\tif ( val ) {\n\t\t\t\tthis.setGridColumnsWidths();\n\t\t\t}\n\t\t};\n\n\t\tthis.getTreeMode = function() {\n\t\t\treturn tree_mode;\n\t\t};\n\n\t\t//Must Set this after set Columns\n\t\tthis.setUnselectedGridData = function( val ) {\n\t\t\tstatic_source_data = val;\n\n\t\t\tif ( !tree_mode ) {\n\t\t\t\tunselect_grid.setData( val );\n\n\t\t\t\tthis.setTotalDisplaySpan();\n\n\t\t\t} else {\n\t\t\t\tthis.reSetUnSelectGridTreeData( val );\n\n\t\t\t}\n\n\t\t\tthis.setUnSelectGridDragAble();\n\n\t\t\tthis.setGridsHeight();\n\t\t};\n\n\t\t/**\n\t\t * This function calculates the optimal widths for awesomebox columns\n\t\t * and whether they should overflow or shrink to fit\n\t\t */\n\t\tthis.setGridColumnsWidths = function() {\n\t\t\tvar primary_grid = unselect_grid;\n\t\t\tvar secondary_grid = select_grid;\n\n\t\t\t//don't swap the grids. always size on left grid.\n\t\t\tvar p_data = primary_grid.getData();\n\t\t\tvar s_data = secondary_grid.getData();\n\t\t\tif ( s_data && s_data.length != 0 && p_data && p_data.length == 0 ) {\n\t\t\t\t//swap grids if no data in primary.\n\t\t\t\tvar temp = primary_grid;\n\t\t\t\tprimary_grid = secondary_grid;\n\t\t\t\tsecondary_grid = temp;\n\t\t\t}\n\n\t\t\t//Make sure what dropdown is expanded, we do not spill over the right edge of the browser causing scrollbars to appear.\n\t\t\tvar max_grid_width = ( ( ( ( Global.bodyWidth() - $( this ).offset().left ) - 100 ) / 2 ) );\n\n\t\t\tvar default_width = primary_grid.setGridColumnsWidth( null, { max_grid_width: max_grid_width } );\n\t\t\tvar colModel = primary_grid.getColumnModel();\n\n\t\t\tsecondary_grid.setGridColumnsWidth( colModel );\n\n\t\t\tvar width = 200;\n\t\t\tvar offset = 28;\n\t\t\t//awesomeboxes with more than 1 column need to adjust for td borders.\n\n\t\t\tvar total_headers_width = 0;\n\t\t\tif ( colModel ) {\n\t\t\t\tfor ( var i = 0; i < colModel.length; i++ ) {\n\t\t\t\t\ttotal_headers_width += colModel[i].widthOrg + 1; //collect the (calculated) column widths (+1 for border\n\t\t\t\t}\n\n\t\t\t\tif ( colModel[0].name == 'cb' ) {\n\t\t\t\t\toffset += 2;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( tree_mode ) {\n\t\t\t\toffset = 26;\n\t\t\t} else {\n\t\t\t\toffset = 22;\n\t\t\t}\n\n\t\t\t//only shrink smaller grids to fit container\n\t\t\tif ( total_headers_width <= ( width ) || colModel.length < 5 ) {\n\t\t\t\t//prevent resize on search.\n\t\t\t\twidth = primary_grid.grid.parents( '.unselect-grid-div, .select-grid-div' ).width() - offset;\n\t\t\t} else {\n\t\t\t\twidth = total_headers_width; //primary_grid.grid.parents( '.unselect-grid-div' ).width() - offset;\n\t\t\t\tif ( default_width > width ) {\n\t\t\t\t\twidth = default_width;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tprimary_grid.setGridWidth( width );\n\t\t\tsecondary_grid.setGridWidth( width );\n\n\t\t\tthis.resizeUnSelectSearchInputs();\n\t\t\tthis.resizeSelectSearchInputs();\n\t\t};\n\n\t\tthis.getPagerData = function() {\n\t\t\treturn pager_data;\n\t\t};\n\n\t\t//Always setPager data no matter static options or api.\n\t\tthis.setPagerData = function( value ) {\n\n\t\t\tpager_data = value;\n\n\t\t\tif ( LocalCacheData.paging_type === 0 ) {\n\t\t\t\tif ( paging_widget.parent().length > 0 ) {\n\t\t\t\t\tpaging_widget.remove();\n\t\t\t\t}\n\n\t\t\t\tpaging_widget.css( 'width', unselect_grid.width() );\n\t\t\t\tunselect_grid.append( paging_widget );\n\n\t\t\t\tpaging_widget.click( function() {\n\t\t\t\t\t$this.onPaging();\n\t\t\t\t} );\n\n\t\t\t\tif ( !pager_data || pager_data.is_last_page || pager_data.last_page_number < 0 ) {\n\t\t\t\t\tpaging_widget.css( 'display', 'none' );\n\t\t\t\t} else {\n\t\t\t\t\tpaging_widget.css( 'display', 'inline-block' );\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tif ( !pager_data || pager_data.last_page_number < 0 ) {\n\t\t\t\t\tleft_buttons_div.css( 'display', 'none' );\n\t\t\t\t\tright_buttons_div.css( 'display', 'none' );\n\n\t\t\t\t} else {\n\t\t\t\t\tleft_buttons_div.css( 'display', 'inline-block' );\n\t\t\t\t\tright_buttons_div.css( 'display', 'inline-block' );\n\n\t\t\t\t\tif ( pager_data.is_last_page === true ) {\n\t\t\t\t\t\tright_buttons_div.addClass( 'disabled' );\n\t\t\t\t\t\tright_buttons_div.addClass( 'disabled-image' );\n\t\t\t\t\t\tright_buttons_enable = false;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tright_buttons_div.removeClass( 'disabled' );\n\t\t\t\t\t\tright_buttons_div.removeClass( 'disabled-image' );\n\t\t\t\t\t\tright_buttons_enable = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( pager_data.is_first_page ) {\n\t\t\t\t\t\tleft_buttons_div.addClass( 'disabled' );\n\t\t\t\t\t\tleft_buttons_div.addClass( 'disabled-image' );\n\t\t\t\t\t\tleft_buttons_enable = false;\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\tleft_buttons_div.removeClass( 'disabled' );\n\t\t\t\t\t\tleft_buttons_div.removeClass( 'disabled-image' );\n\t\t\t\t\t\tleft_buttons_enable = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\ta_dropdown_this.setTotalDisplaySpan();\n\t\t};\n\n\t\tthis.onPaging = function() {\n\t\t\tparent_a_combo_box.onADropDownSearch( 'unselect_grid', 'next' );\n\t\t};\n\n\t\tthis.reSetUnSelectGridTreeData = function( val ) {\n\t\t\tvar scroll_position = unselect_grid.grid.parent().parent().scrollTop();\n\t\t\tvar grid_data = unselect_grid.getData();\n\t\t\tif ( grid_data && grid_data.length > 0 && val && val.length > 0 ) {\n\t\t\t\t//If in tree_mode, don't clear the unselected grid, since we just bold/unbold the selected items otherwise the \"tree\" layout would be lost.\n\t\t\t\tunselect_grid.setData( val, !tree_mode );\n\t\t\t} else {\n\t\t\t\tvar col_model = unselect_grid.getGridParam( 'colModel' );\n\n\t\t\t\tif ( !unselect_grid.grid.is( ':visible' ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tunselect_grid.grid.jqGrid( 'GridUnload' );\n\t\t\t\tunselect_grid = $( this ).find( '.unselect-grid' );\n\t\t\t\tunselect_grid = unselect_grid.grid = new TTGrid( $( this ).find( '.unselect-grid' ).attr( 'id' ), {\n\t\t\t\t\tcontainer_selector: '.unselect-grid-div',\n\t\t\t\t\taltRows: true,\n\t\t\t\t\tdatastr: val,\n\t\t\t\t\tdatatype: 'jsonstring',\n\t\t\t\t\tsortable: false,\n\t\t\t\t\twidth: 440,\n\t\t\t\t\tonResizeGrid: resize_grids,\n\t\t\t\t\t//maxHeight: default_height,\n\t\t\t\t\tcolNames: [],\n\t\t\t\t\trowNum: 10000,\n\t\t\t\t\tcolModel: col_model,\n\t\t\t\t\tondblClickRow: a_dropdown_this.onUnSelectGridDoubleClick,\n\t\t\t\t\tgridview: true,\n\t\t\t\t\ttreeGrid: true,\n\t\t\t\t\ttreeGridModel: 'adjacency',\n\t\t\t\t\ttreedatatype: 'local',\n\t\t\t\t\tExpandColumn: 'name',\n\t\t\t\t\tmultiselect: allow_multiple_selection,\n\t\t\t\t\tmultiselectPosition: 'none',\n\t\t\t\t\twinMultiSelect: allow_multiple_selection,\n\t\t\t\t\tonCellSelect: function( id, k, el, e ) {\n\t\t\t\t\t\tif ( $( e.target ).prop( 'class' ).indexOf( 'ui-icon-triangle' ) != -1 ) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tid = Global.convertToNumberIfPossible( id );\n\n\t\t\t\t\t\tif ( !allow_multiple_selection ) {\n\t\t\t\t\t\t\tvar source_data = unselect_grid.getGridParam( 'data' );\n\t\t\t\t\t\t\t$.each( source_data, function( index, content ) {\n\t\t\t\t\t\t\t\tif ( tree_mode && key == 'id' ) {\n\t\t\t\t\t\t\t\t\tkey = '_id_';\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif ( content[key] == id ) {\n\t\t\t\t\t\t\t\t\tselect_item = content;\n\t\t\t\t\t\t\t\t\tisChanged = true;\n\t\t\t\t\t\t\t\t\tif ( !LocalCacheData.currently_collapsing_navigation_tree_element ) { //#2583 - must allow null or false\n\t\t\t\t\t\t\t\t\t\ta_dropdown_this.trigger( 'close', [a_dropdown_this] );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn;\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}\n\n\t\t\t\t\t\tif ( on_tree_grid_row_select ) {\n\t\t\t\t\t\t\ton_tree_grid_row_select( id, LocalCacheData.currently_collapsing_navigation_tree_element );\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tbeforeSelectRow: function( iRow, e ) {\n\t\t\t\t\t\tvar $td = $( e.target ).closest( 'tr.jqgrow>td' ),\n\t\t\t\t\t\t\tiCol = $td.length > 0 ? $td[0].cellIndex : -1,\n\t\t\t\t\t\t\tp = $( this ).jqGrid( 'getGridParam' ),\n\t\t\t\t\t\t\tcm = iCol >= 0 ? p.colModel[iCol] : null;\n\n\t\t\t\t\t\tif ( cm != null && cm.name === p.ExpandColumn &&\n\t\t\t\t\t\t\t$( e.target ).closest( '.tree-wrap' ).length > 0 ) {\n\n\t\t\t\t\t\t\treturn false; // prevent row selection\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tjsonReader: {\n\t\t\t\t\t\trepeatitems: false,\n\t\t\t\t\t\troot: function( obj ) {\n\t\t\t\t\t\t\treturn obj;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpage: function( obj ) {\n\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttotal: function( obj ) {\n\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\t},\n\t\t\t\t\t\trecords: function( obj ) {\n\t\t\t\t\t\t\treturn obj.length;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tonResizeGrid: resize_grids\n\t\t\t\t}, col_model );\n\t\t\t}\n\t\t\tscroll_position > 0 && unselect_grid.grid.parent().parent().scrollTop( scroll_position );\n\t\t\tthis.setGridsHeight();\n\n\t\t\tvar select_items = this.getSelectItems();\n\t\t\t$( this ).find( 'tr' ).removeClass( 'selected-tree-cell' );\n\t\t\tfor ( var i = ( select_items.length - 1 ); i >= 0; i-- ) {\n\t\t\t\t$( this ).find( '.unselect-grid-div' ).find( 'tr#' + select_items[i].id ).addClass( 'selected-tree-cell' );\n\t\t\t}\n\t\t};\n\n\t\tthis.setGridsHeight = function() {\n\t\t\t//Calculate the max possible size of awesomebox.\n\n\t\t\tif ( static_height ) {\n\t\t\t\tunselect_grid.grid.setGridHeight( static_height );\n\t\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\t\tselect_grid.grid.setGridHeight( static_height );\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( !parent_a_combo_box ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar top_offset = parent_a_combo_box.offset().top;\n\t\t\tvar bottom_offset = Global.bodyHeight() - top_offset - 30;\n\t\t\tvar new_height = top_offset > bottom_offset ? top_offset : bottom_offset;\n\n\t\t\tnew_height = new_height - 130;\n\n\t\t\tvar source_data = parent_a_combo_box.getStaticSourceData();\n\n\t\t\tif ( !source_data ) {\n\t\t\t\tnew_height = default_height;\n\t\t\t} else {\n\t\t\t\tvar source_height = source_data.length * 23;\n\n\t\t\t\tif ( source_height < default_height ) {\n\t\t\t\t\tnew_height = default_height;\n\t\t\t\t} else if ( source_height > default_height && source_height < new_height ) {\n\t\t\t\t\tnew_height = source_height;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( max_height && max_height < new_height ) {\n\t\t\t\tnew_height = max_height;\n\t\t\t}\n\n\t\t\tunselect_grid.grid.setGridHeight( new_height );\n\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\tselect_grid.grid.setGridHeight( new_height );\n\t\t\t}\n\n\t\t\tthis.setPosition( top_offset, new_height );\n\n\t\t};\n\n\t\tthis.setPosition = function( top_offset, new_height ) {\n\n\t\t\tif ( top_offset + new_height + 130 < Global.bodyHeight() ) {\n\t\t\t\ta_dropdown_this.parent().css( 'top', top_offset + 25 );\n\t\t\t} else {\n\n\t\t\t\tif ( new_height != default_height ) {\n\t\t\t\t\ta_dropdown_this.parent().css( 'top', ( top_offset - new_height - 125 ) );\n\t\t\t\t} else {\n\t\t\t\t\ta_dropdown_this.parent().css( 'top', ( top_offset - new_height - 125 ) );\n\t\t\t\t}\n\n\t\t\t}\n\t\t};\n\n\t\tthis.onTreeCellFormat = function( cell_value, related_data, row ) {\n\t\t\tvar selected_items = a_dropdown_this.getSelectItems();\n\t\t\tfor ( var i = 0, m = selected_items.length; i < m; i++ ) {\n\t\t\t\tvar item = selected_items[i];\n\t\t\t\tif ( item.name === cell_value ) {\n\t\t\t\t\treturn '<span class=\"selected-tree-cell\">' + cell_value + '</span>';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn cell_value;\n\t\t};\n\n\t\t//Do this before set data\n\t\tthis.setColumns = function( val ) {\n\n\t\t\tfor ( var a = 0; a < val.length; a++ ) {\n\t\t\t\tval[a].resizable = false;\n\t\t\t}\n\n\t\t\tunselect_grid.grid.jqGrid( 'GridUnload' );\n\t\t\tunselect_grid = $( this ).find( '.unselect-grid' );\n\t\t\tunselect_grid.getGridParam();\n\t\t\tvar unselect_grid_search_div = $( this ).find( '.unselect-grid-search-div' );\n\t\t\tvar select_grid_search_div = $( this ).find( '.select-grid-search-div' );\n\n\t\t\tvar gridWidth = $( '.unselect-grid-border-div' ).width() - 2; // single-column width\n\t\t\tif ( show_search_inputs ) {\n\t\t\t\tgridWidth -= 15;\n\t\t\t}\n\n\t\t\tgridWidth = val.length * 125;\n\t\t\tif ( gridWidth < 438 ) {\n\t\t\t\tbox_width = gridWidth = 438;\n\t\t\t}\n\t\t\tif ( val.length > 1 ) {\n\n\t\t\t\tbox_width = gridWidth;\n\t\t\t\tif ( allow_multiple_selection && gridWidth > ( Global.bodyWidth() / 2 - 30 - 15 ) ) {\n\t\t\t\t\tbox_width = ( Global.bodyWidth() / 2 - 30 - 15 );\n\t\t\t\t} else if ( !allow_multiple_selection && gridWidth > ( Global.bodyWidth() - 30 - 15 ) ) {\n\t\t\t\t\tbox_width = ( Global.bodyWidth() - 30 - 15 );\n\t\t\t\t}\n\n\t\t\t\tthis.find( '.unselect-grid-div' ).width( null );\n\t\t\t\tthis.find( '.unselect-grid-border-div' ).width( null );\n\n\t\t\t\tthis.find( '.select-grid-div' ).width( null );\n\t\t\t\tthis.find( '.select-grid-border-div' ).width( null );\n\n\t\t\t\tif ( show_search_inputs ) {\n\t\t\t\t\tunselect_grid_search_div.css( 'width', null );\n\t\t\t\t\tselect_grid_search_div.css( 'width', null );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbox_width = gridWidth;\n\t\t\t}\n\n\t\t\tif ( !tree_mode ) {\n\t\t\t\tunselect_grid = new TTGrid( $( unselect_grid ).attr( 'id' ), {\n\t\t\t\t\tcontainer_selector: '.unselect-grid-div',\n\t\t\t\t\taltRows: true,\n\t\t\t\t\tdata: [],\n\t\t\t\t\tdatatype: 'local',\n\t\t\t\t\tsortable: false,\n\t\t\t\t\twidth: gridWidth,\n\t\t\t\t\t//maxHeight: default_height,\n\t\t\t\t\tcolNames: [],\n\t\t\t\t\trowNum: 10000,\n\t\t\t\t\tkeep_scroll_place: true,\n\t\t\t\t\tondblClickRow: a_dropdown_this.onUnSelectGridDoubleClick,\n\t\t\t\t\tcolModel: val,\n\t\t\t\t\tmultiselect: allow_multiple_selection,\n\t\t\t\t\tmultiboxonly: allow_multiple_selection,\n\t\t\t\t\tviewrecords: true,\n\t\t\t\t\tediturl: 'clientArray',\n\t\t\t\t\tresizeStop: function() {\n\t\t\t\t\t\ta_dropdown_this.resizeUnSelectSearchInputs();\n\t\t\t\t\t},\n\t\t\t\t\tonCellSelect: function( id ) {\n\t\t\t\t\t\tid = Global.convertToNumberIfPossible( id );\n\n\t\t\t\t\t\tif ( !allow_multiple_selection ) {\n\n\t\t\t\t\t\t\tvar source_data = unselect_grid.getGridParam( 'data' );\n\n\t\t\t\t\t\t\t$.each( source_data, function( index, content ) {\n\n\t\t\t\t\t\t\t\tif ( key !== 'id' ) {\n\t\t\t\t\t\t\t\t\tif ( content['id'] == id ) {\n\t\t\t\t\t\t\t\t\t\tselect_item = content;\n\t\t\t\t\t\t\t\t\t\tisChanged = true;\n\t\t\t\t\t\t\t\t\t\ta_dropdown_this.trigger( 'close', [a_dropdown_this] );\n\t\t\t\t\t\t\t\t\t\treturn false;\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\tif ( content[key] == id ) {\n\t\t\t\t\t\t\t\t\t\tselect_item = content;\n\t\t\t\t\t\t\t\t\t\tisChanged = true;\n\t\t\t\t\t\t\t\t\t\ta_dropdown_this.trigger( 'close', [a_dropdown_this] );\n\t\t\t\t\t\t\t\t\t\treturn false;\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} );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( unselect_grid_last_row ) {\n\t\t\t\t\t\t\tunselect_grid.grid.jqGrid( 'saveRow', unselect_grid_last_row );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tunselect_grid.grid.jqGrid( 'editRow', id, true );\n\t\t\t\t\t\tunselect_grid_last_row = id;\n\n\t\t\t\t\t\ta_dropdown_this.setTotalDisplaySpan();\n\n\t\t\t\t\t\tfunction getSelectValue() {\n\t\t\t\t\t\t\tvar len = source_data.length;\n\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tonResizeGrid: resize_grids\n\t\t\t\t}, val );\n\n\t\t\t} else {\n\t\t\t\tif ( tree_mode ) {\n\t\t\t\t\tvar tree_columns = _.map( val, _.clone );\n\t\t\t\t\t_.map( tree_columns, function( item ) {\n\t\t\t\t\t\titem.formatter = a_dropdown_this.onTreeCellFormat;\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\tunselect_grid = new TTGrid( $( unselect_grid ).attr( 'id' ), {\n\t\t\t\t\tcontainer_selector: '.unselect-grid-div',\n\t\t\t\t\taltRows: true,\n\t\t\t\t\tdatastr: [],\n\t\t\t\t\tdatatype: 'jsonstring',\n\t\t\t\t\tsortable: false,\n\t\t\t\t\twidth: gridWidth,\n\t\t\t\t\tmaxHeight: default_height,\n\t\t\t\t\tcolNames: [],\n\t\t\t\t\trowNum: 10000,\n\t\t\t\t\tcolModel: tree_columns,\n\t\t\t\t\tondblClickRow: a_dropdown_this.onUnSelectGridDoubleClick,\n\t\t\t\t\tonCellSelect: function() {\n\t\t\t\t\t\ta_dropdown_this.onUnSelectGridSelectRow();\n\t\t\t\t\t},\n\t\t\t\t\tgridview: true,\n\t\t\t\t\ttreeGrid: true,\n\t\t\t\t\ttreeGridModel: 'adjacency',\n\t\t\t\t\ttreedatatype: 'local',\n\t\t\t\t\tExpandColumn: 'name',\n\t\t\t\t\tmultiselect: false, //allow_multiple_selection,\n\n\t\t\t\t\tjsonReader: {\n\t\t\t\t\t\trepeatitems: false,\n\t\t\t\t\t\troot: function( obj ) {\n\t\t\t\t\t\t\treturn obj;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpage: function( obj ) {\n\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttotal: function( obj ) {\n\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\t},\n\t\t\t\t\t\trecords: function( obj ) {\n\t\t\t\t\t\t\treturn obj.length;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\n\t\t\t\t\tonSelectRow: function( id ) {\n\t\t\t\t\t\tif ( on_tree_grid_row_select ) {\n\t\t\t\t\t\t\ton_tree_grid_row_select( id );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tid = Global.convertToNumberIfPossible( id );\n\n\t\t\t\t\t},\n\n\t\t\t\t\tonResizeGrid: resize_grids\n\t\t\t\t}, tree_columns );\n\t\t\t}\n\n\t\t\tthis.collectUnselectGridColumns(); //Make each column as THeader plugin and save them\n\n\t\t\tif ( show_search_inputs ) {\n\t\t\t\tif ( !parent_a_combo_box || !parent_a_combo_box.getAPI() ) {\n\t\t\t\t\tthis.setLocalSearchMode( true ); //If no API allow local searching of the dropdown items.\n\t\t\t\t}\n\t\t\t\tthis.buildUnSelectSearchInputs(); //Build search input above columns\n\t\t\t}\n\n\t\t\tselect_grid.grid.jqGrid( 'GridUnload' );\n\t\t\tselect_grid = $( this ).find( '.select-grid' );\n\t\t\tselect_grid = new TTGrid( $( select_grid ).attr( 'id' ), {\n\t\t\t\tcontainer_selector: '.select-grid-div',\n\t\t\t\taltRows: true,\n\t\t\t\tdata: [],\n\t\t\t\tdatatype: 'local',\n\t\t\t\tsortable: false,\n\t\t\t\twidth: gridWidth,\n\t\t\t\t//maxHeight: default_height,\n\t\t\t\tcolNames: [],\n\t\t\t\trowNum: 10000,\n\t\t\t\tondblClickRow: this.onSelectGridDoubleClick,\n\t\t\t\tcolModel: val,\n\t\t\t\tmultiselect: allow_multiple_selection,\n\t\t\t\tmultiboxonly: allow_multiple_selection,\n\t\t\t\tviewrecords: true,\n\t\t\t\tkeep_scroll_place: true,\n\t\t\t\tresizeStop: function() {\n\t\t\t\t\ta_dropdown_this.resizeSelectSearchInputs();\n\t\t\t\t},\n\t\t\t\tonCellSelect: function( id ) {\n\t\t\t\t\tif ( id ) {\n\n\t\t\t\t\t\tif ( select_grid_last_row ) {\n\t\t\t\t\t\t\tselect_grid.grid.jqGrid( 'saveRow', select_grid_last_row );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tselect_grid.grid.jqGrid( 'editRow', id, true );\n\t\t\t\t\t\tselect_grid_last_row = id;\n\t\t\t\t\t}\n\n\t\t\t\t},\n\t\t\t\tonResizeGrid: resize_grids\n\t\t\t}, val );\n\n\t\t\tthis.collectSelectGridColumns(); //Make each column as THeader plugin and save them\n\t\t\tif ( show_search_inputs ) {\n\t\t\t\tif ( !parent_a_combo_box || !parent_a_combo_box.getAPI() ) {\n\t\t\t\t\tthis.setLocalSearchMode( true ); //If no API allow local searching of the dropdown items.\n\t\t\t\t}\n\t\t\t\tthis.buildSelectSearchInputs(); //Build search input above columns\n\t\t\t}\n\n\t\t};\n\n\t\tthis.buildSelectSearchInputs = function() {\n\t\t\tvar len = select_grid_header_array.length;\n\n\t\t\tvar search_div = $( this ).find( '.select-grid-search-div' );\n\t\t\tvar first_column_width = 0;\n\t\t\tvar search_input_array = [];\n\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\tvar header = select_grid_header_array[i];\n\n\t\t\t\tif ( i === 0 ) {\n\t\t\t\t\tfirst_column_width = header.getWidth();\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if ( allow_multiple_selection && i === 1 ) {\n\t\t\t\t\tvar search_input = $( '<input type=\\'text\\' class=\\'search-input\\'>' );\n\t\t\t\t\tsearch_input.css( 'width', header.getWidth() + first_column_width );\n\t\t\t\t} else {\n\t\t\t\t\tsearch_input = $( '<input type=\\'text\\' class=\\'search-input\\'>' );\n\t\t\t\t\tsearch_input.css( 'width', header.getWidth() );\n\t\t\t\t}\n\n\t\t\t\tsearch_input.on( 'drop', function( e ) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t} );\n\n\t\t\t\tsearch_input.ASearchInput( { column_model: header.getColumnModel() } ); //Make it as ASearchInout Widget;\n\n\t\t\t\tsearch_div.append( search_input );\n\t\t\t\tsearch_input_array.push( search_input );\n\t\t\t\t//Set cached seach_input data back, usually in navigation_mode\n\t\t\t\tif ( select_grid_search_map ) {\n\t\t\t\t\tsearch_input.setFilter( select_grid_search_map );\n\n\t\t\t\t}\n\n\t\t\t\tsearch_input.bind( 'searchEnter', function( e, searchVal, field ) {\n\n\t\t\t\t\tif ( a_dropdown_this.getValue().length < 1 ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( !select_grid_search_map ) {\n\t\t\t\t\t\tselect_grid_search_map = {};\n\t\t\t\t\t}\n\n\t\t\t\t\tdelete select_grid_search_map.id;\n\n\t\t\t\t\tif ( !searchVal ) {\n\t\t\t\t\t\tdelete select_grid_search_map[field];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tselect_grid_search_map[field] = searchVal;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( a_dropdown_this.isLocalSearchMode() ) {\n\t\t\t\t\t\ta_dropdown_this.localSearch( 'select', select_grid_search_map );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparent_a_combo_box.setCachedSelectGridSearchInputsFilter( Global.clone( select_grid_search_map ) );\n\t\t\t\t\t\tparent_a_combo_box.onADropDownSearch();\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t\tvar close_btn = $( '<button class=\"close-btn\"><img src=\"' + Global.getRealImagePath( 'images/close.png' ) + '\"></img></button>' );\n\n\t\t\t//close_btn.width( unselect_grid_header_array[0].getWidth() + 2 );\n\t\t\t//close_btn.width( 22 );\n\t\t\tsearch_div.prepend( close_btn );\n\t\t\tvar $this = this;\n\t\t\tclose_btn.click( function() { //clear search inputs for select box\n\t\t\t\tselect_grid_search_map = {};\n\t\t\t\tif ( a_dropdown_this.isLocalSearchMode() ) {\n\t\t\t\t\ta_dropdown_this.localSearch( 'select', select_grid_search_map );\n\t\t\t\t} else {\n\t\t\t\t\tparent_a_combo_box.setCachedSelectGridSearchInputsFilter( select_grid_search_map );\n\t\t\t\t\tparent_a_combo_box.onADropDownSearch();\n }\n\t\t\t\tfor ( var i = 0; i < search_input_array.length; i++ ) {\n\t\t\t\t\tvar s_i = search_input_array[i];\n\t\t\t\t\ts_i.clearValue();\n\t\t\t\t}\n\t\t\t} );\n\t\t};\n\n\t\tthis.localSearch = function( grid_type, grid_search_map, optional_filter ) {\n\t\t\tif ( !optional_filter ) {\n\t\t\t\t//Replicates API Search functionality where newly added records are shown even if they don't match the search criteria.\n\t\t\t\toptional_filter = [];\n\t\t\t\tlocal_search_optional_filter = [];\n\t\t\t}\n\n\t\t\t//Merge in repeated optional search, so that user adding 1 by 1 will continue to see all new items.\n\t\t\tlocal_search_optional_filter = local_search_optional_filter.concat( optional_filter );\n\n\t\t\tlet search_grid = null;\n\t\t\tlet search_items = [];\n\n\t\t\tif ( grid_type === 'select' ) {\n\t\t\t\tsearch_grid = select_grid;\n\t\t\t} else {\n\t\t\t\tsearch_grid = unselect_grid;\n\t\t\t}\n\n\t\t\tsearch_grid.resetSelection(); //Reset all checked items to replicate behavior of API search.\n\n\t\t\tsearch_items = search_grid.getData();\n\n\t\t\t//Need to search against multiple terms and columns.\n\t\t\tlet meetAllSearchCriteria = ( item, grid_search_map ) => {\n\t\t\t\tfor ( let key in grid_search_map ) {\n\t\t\t\t\tif ( grid_search_map.hasOwnProperty( key ) ) {\n\t\t\t\t\t\tlet value = grid_search_map[key].trim();\n\t\t\t\t\t\tif ( !item[key] || item[key].toLowerCase().includes( value.toLowerCase() ) === false ) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\tfor ( let i = 0; i < search_items.length; i++ ) {\n\t\t\t\tif ( _.isEmpty( grid_search_map ) || local_search_optional_filter.some( item => item.id === search_items[i].id ) || meetAllSearchCriteria( search_items[i], grid_search_map ) ) {\n\t\t\t\t\t$( search_grid.grid ).find( '[id=\"' + search_items[i].id + '\"]' ).show();\n\t\t\t\t\tsearch_items[i].hidden = false;\n\t\t\t\t} else {\n\t\t\t\t\t$( search_grid.grid ).find( '[id=\"' + search_items[i].id + '\"]' ).hide();\n\t\t\t\t\tsearch_items[i].hidden = true; //Hidden items are not selectable even with \"Select all\"\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tthis.resizeUnSelectSearchInputs = function() {\n\t\t\tvar search_div = $( this ).find( '.unselect-grid-search-div' );\n\n\t\t\tvar search_inputs = search_div.find( '.search-input' );\n\t\t\tvar first_column_width;\n\t\t\tvar unselect_grid_search_div = $( this ).find( '.unselect-grid-search-div' );\n\n\t\t\tvar len = search_inputs.length;\n\t\t\tvar header;\n\t\t\tvar search_input;\n\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\tfirst_column_width = unselect_grid_header_array[0].width();\n\n\t\t\t\tif ( len == 1 ) {\n\t\t\t\t\theader = unselect_grid_header_array[1];\n\t\t\t\t\tsearch_input = $( search_inputs[0] );\n\t\t\t\t\tsearch_input.css( 'width', header.getWidth() );\n\t\t\t\t} else {\n\t\t\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\t\t\theader = unselect_grid_header_array[i + 1];\n\t\t\t\t\t\tsearch_input = $( search_inputs[i] );\n\t\t\t\t\t\tif ( i == ( len - 1 ) ) {\n\t\t\t\t\t\t\tsearch_input.css( 'width', header.getWidth() );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsearch_input.css( 'width', header.getWidth() + 1 );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\theader = unselect_grid_header_array[i];\n\t\t\t\t\tsearch_input = $( search_inputs[i] );\n\t\t\t\t\tif ( i === 0 ) {\n\t\t\t\t\t\tsearch_input.css( 'width', header.getWidth() - 22 );\n\t\t\t\t\t} else if ( i == ( len - 1 ) ) {\n\t\t\t\t\t\tsearch_input.css( 'width', header.getWidth() + 1 );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsearch_input.css( 'width', header.getWidth() + 1 );\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar unselect_grid_width = unselect_grid.grid.parents( '.ui-jqgrid-jquery-ui' ).width() ? unselect_grid.grid.parent().parent().width() : 100;\n\t\t\tunselect_grid.setGridWidth( unselect_grid_width );\n\t\t\t//var unselect_grid_width = unselect_grid.getWidth();\n\t\t\tvar unselect_grid_search_div_width = unselect_grid_width;\n\t\t\tif ( tree_mode ) {\n\t\t\t\tunselect_grid_width = unselect_grid.getWidth();\n\t\t\t}\n\n\t\t\tvar outer_box_width = unselect_grid_width + 22;\n\t\t\tvar inner_box_width = unselect_grid_width + 4;\n\t\t\tvar max_width = ( $( 'body' ).width() - 30 );\n\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\tmax_width = ( ( $( 'body' ).width() / 2 ) - 30 );\n\t\t\t}\n\n\t\t\tif ( outer_box_width > max_width ) {\n\t\t\t\touter_box_width = max_width;\n\t\t\t\tinner_box_width = max_width - 17;\n\t\t\t}\n\n\t\t\tunselect_grid.grid.parents( '.unselect-grid-div' ).css( 'width', outer_box_width ); //outer blue box width\n\t\t\tunselect_grid.grid.parents( '.unselect-grid-border-div' ).css( 'width', inner_box_width ); //red border div.\n\t\t\tunselect_grid_search_div.css( 'width', unselect_grid_search_div_width );\n\t\t};\n\n\t\tthis.resizeSelectSearchInputs = function() {\n\t\t\tvar search_div = $( this ).find( '.select-grid-search-div' );\n\n\t\t\tvar search_inputs = search_div.find( '.search-input' );\n\t\t\tvar first_column_width;\n\t\t\tvar select_grid_search_div = $( this ).find( '.select-grid-search-div' );\n\n\t\t\tvar len = search_inputs.length;\n\n\t\t\tfirst_column_width = select_grid_header_array[0].width() + 5;\n\t\t\tif ( len == 1 ) {\n\t\t\t\theader = unselect_grid_header_array[1];\n\t\t\t\tsearch_input = $( search_inputs[0] );\n\t\t\t\tsearch_input.css( 'width', header.getWidth() );\n\t\t\t} else {\n\t\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\t\tvar header = select_grid_header_array[i + 1];\n\t\t\t\t\tvar search_input = $( search_inputs[i] );\n\t\t\t\t\tif ( i == ( len - 1 ) ) {\n\t\t\t\t\t\tsearch_input.css( 'width', header.getWidth() );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsearch_input.css( 'width', header.getWidth() + 1 );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar newWidth = select_grid.grid.parents( '.ui-jqgrid-jquery-ui' ).width() ? select_grid.grid.parent().parent().width() : 100;\n\t\t\tselect_grid.setGridWidth( newWidth );\n\n\t\t\tvar outer_box_width = newWidth + 22;\n\t\t\tvar inner_box_width = newWidth + 4;\n\n\t\t\tvar max_width = ( ( $( 'body' ).width() / 2 ) - 30 );\n\n\t\t\tif ( outer_box_width > max_width ) {\n\t\t\t\touter_box_width = max_width;\n\t\t\t\tinner_box_width = max_width - 17;\n\t\t\t}\n\n\t\t\tselect_grid.grid.parents( '.select-grid-div' ).css( 'width', outer_box_width ); //outer blue box width\n\t\t\tselect_grid.grid.parents( '.select-grid-border-div' ).css( 'width', inner_box_width ); //red border div.\n\t\t\tselect_grid_search_div.css( 'width', newWidth );\n\t\t};\n\n\t\tthis.buildUnSelectSearchInputs = function() {\n\t\t\tvar len = unselect_grid_header_array.length;\n\n\t\t\tvar search_div = $( this ).find( '.unselect-grid-search-div' );\n\t\t\tvar first_column_width = 0;\n\t\t\tvar search_input_array = [];\n\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\tvar header = unselect_grid_header_array[i];\n\n\t\t\t\tif ( allow_multiple_selection && i === 0 ) {\n\t\t\t\t\tfirst_column_width = header.getWidth();\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if ( allow_multiple_selection && i === 1 ) {\n\t\t\t\t\tvar search_input = $( '<input type=\\'text\\' class=\\'search-input unselect-grid-search-input\\'>' );\n\t\t\t\t\tvar width = header.getWidth() + first_column_width - 2;\n\t\t\t\t\tsearch_input.css( 'width', width );\n\t\t\t\t} else {\n\t\t\t\t\tsearch_input = $( '<input type=\\'text\\' class=\\'search-input\\'>' );\n\t\t\t\t\tif ( i == ( len - 1 ) ) {\n\t\t\t\t\t\tsearch_input.css( 'width', header.getWidth() + 1 + 'px' );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsearch_input.css( 'width', header.getWidth() + 'px' );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tsearch_input.on( 'drop', function( e ) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t} );\n\n\t\t\t\tsearch_input.ASearchInput( { column_model: header.getColumnModel() } ); //Make it as ASearchInout Widget;\n\n\t\t\t\tsearch_div.append( search_input );\n\t\t\t\tsearch_input_array.push( search_input );\n\n\t\t\t\t//Set cached seach_input data back, unsualy in navigation_mode\n\t\t\t\tif ( unselect_grid_search_map ) {\n\t\t\t\t\tsearch_input.setFilter( unselect_grid_search_map );\n\n\t\t\t\t}\n\n\t\t\t\t//Do Column Search\n\t\t\t\tsearch_input.bind( 'searchEnter', function( e, searchVal, field ) {\n\n\t\t\t\t\tif ( !unselect_grid_search_map ) {\n\t\t\t\t\t\tunselect_grid_search_map = {};\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( !searchVal ) {\n\t\t\t\t\t\tdelete unselect_grid_search_map[field];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tunselect_grid_search_map[field] = searchVal;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( a_dropdown_this.isLocalSearchMode() ) {\n\t\t\t\t\t\t//Search in local data may not always have a parent_a_combo_box such as in the case of Permission Groups.\n\t\t\t\t\t\ta_dropdown_this.localSearch( 'unselect', unselect_grid_search_map );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparent_a_combo_box.setCachedSearchInputsFilter( unselect_grid_search_map );\n\t\t\t\t\t\tparent_a_combo_box.onADropDownSearch( 'unselect_grid' );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t\tvar close_btn = $( '<button class=\"close-btn\"><img src=\"' + Global.getRealImagePath( 'images/close.png' ) + '\"></img></button>' );\n\n\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\t//close_btn.width( 22 )\n\t\t\t} else {\n\t\t\t\t//close_btn.width( 14 );\n\t\t\t}\n\n\t\t\tsearch_div.prepend( close_btn );\n\t\t\tclose_btn.click( function() {\n\t\t\t\tunselect_grid_search_map = {};\n\t\t\t\tif ( a_dropdown_this.isLocalSearchMode() ) {\n\t\t\t\t\ta_dropdown_this.localSearch( 'unselect', unselect_grid_search_map );\n\t\t\t\t} else {\n\t\t\t\t\tparent_a_combo_box.setCachedSearchInputsFilter( unselect_grid_search_map );\n\t\t\t\t\tparent_a_combo_box.onADropDownSearch( 'unselect_grid' );\n\t\t\t\t}\n\t\t\t\tfor ( var i = 0; i < search_input_array.length; i++ ) {\n\n\t\t\t\t\tvar s_i = search_input_array[i];\n\t\t\t\t\ts_i.clearValue();\n\t\t\t\t}\n\t\t\t} );\n\n\t\t};\n\n\t\t//Set select item when not allow multiple selection\n\t\t// *IMPORTANT* This cannot be defined as this.setSelectItem() as it will break.\n\t\tsetSelectItem = function( val ) {\n\t\t\tselect_item = val;\n\t\t};\n\n\t\t//Search Reesult in select grid. it's not effect the selectitems when getSelectItems\n\t\tthis.setSelectGridSearchResult = function( val ) {\n\n\t\t\tif ( !real_selected_items || real_selected_items.length == 0 ) {\n\t\t\t\t//Clone the array with .slice(), this fixes the bug where you have an empty dropdown (no selected items)\n\t\t\t\t//You move 5 items to the right side, then search within those items to show only 1, then clear the search, and only 1 item would still be shown.\n\t\t\t\treal_selected_items = this.getSelectItems().slice();\n\t\t\t}\n\t\t\tselect_grid.setData( val );\n\t\t};\n\n\t\t//Must Set this after setUnselectedGridData for now\n\t\t//Remove select items form allColumn array\n\t\tthis.setSelectGridData = function( val, searchResult ) {\n\t\t\tif ( parent_a_combo_box && parent_a_combo_box.getAPI() ) {\n\t\t\t\tval = Global.formatGridData( val, parent_a_combo_box.getAPI().key_name );\n\t\t\t}\n\t\t\tif ( Object.prototype.toString.call( static_source_data ) !== '[object Array]' || static_source_data.length < 1 ) {\n\t\t\t\tstatic_source_data = [];\n\t\t\t}\n\t\t\t//Uncaught TypeError: Cannot read property 'length' of undefined\n\t\t\tif ( !val ) {\n\t\t\t\tval = [];\n\t\t\t}\n\t\t\tvar all_columns = static_source_data.slice(); //Copy from Static data\n\t\t\tvar i;\n\t\t\tvar j;\n\t\t\tvar select_item;\n\t\t\tvar tmp_select_items;\n\t\t\tvar all_columns_len;\n\t\t\tif ( all_columns && all_columns.length > 0 ) {\n\t\t\t\tvar selectItemLen = val.length;\n\t\t\t\tif ( !auto_sort ) {\n\n\t\t\t\t\tfor ( i = 0; i < selectItemLen; i++ ) {\n\t\t\t\t\t\tselect_item = val[i];\n\t\t\t\t\t\tif ( !Global.isSet( select_item[key] ) ) {\n\t\t\t\t\t\t\tselect_item = [];\n\t\t\t\t\t\t\tselect_item[key] = val[i];\n\t\t\t\t\t\t\tif ( !Global.isSet( tmp_select_items ) ) {\n\t\t\t\t\t\t\t\ttmp_select_items = [];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tall_columns_len = all_columns.length;\n\t\t\t\t\t\tfor ( j = 0; j < all_columns_len; j++ ) {\n\t\t\t\t\t\t\tvar fromAllColumn = all_columns[j];\n\t\t\t\t\t\t\tif ( fromAllColumn[key] == select_item[key] ) {\n\t\t\t\t\t\t\t\t//saved search select items may don't have ids if it's saved from flex, so set it back\n\t\t\t\t\t\t\t\tif ( !select_item.hasOwnProperty( 'id' ) && fromAllColumn.hasOwnProperty( 'id' ) ) {\n\t\t\t\t\t\t\t\t\tselect_item.id = fromAllColumn.id;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif ( Global.isSet( tmp_select_items ) ) {\n\t\t\t\t\t\t\t\t\ttmp_select_items.push( fromAllColumn );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif ( !tree_mode ) {\n\t\t\t\t\t\t\t\t\tall_columns.splice( j, 1 );\n\t\t\t\t\t\t\t\t}\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\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\tall_columns_len = all_columns.length;\n\t\t\t\t\tfor ( j = 0; j < all_columns_len; j++ ) {\n\t\t\t\t\t\tfromAllColumn = all_columns[j];\n\t\t\t\t\t\tfor ( i = 0; i < selectItemLen; i++ ) {\n\t\t\t\t\t\t\tselect_item = val[i];\n\t\t\t\t\t\t\tif ( !Global.isSet( select_item[key] ) ) {\n\t\t\t\t\t\t\t\tselect_item = [];\n\t\t\t\t\t\t\t\tselect_item[key] = val[i];\n\t\t\t\t\t\t\t\tif ( !Global.isSet( tmp_select_items ) ) {\n\t\t\t\t\t\t\t\t\ttmp_select_items = [];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// we have both string case and number case. sometimes number will be 'xx'. So use == make sure all match\n\t\t\t\t\t\t\tif ( fromAllColumn[key] == select_item[key] ) {\n\t\t\t\t\t\t\t\t//saved search select items may don't have ids if it's saved from flex, so set it back\n\t\t\t\t\t\t\t\tif ( !select_item.hasOwnProperty( 'id' ) && fromAllColumn.hasOwnProperty( 'id' ) ) {\n\t\t\t\t\t\t\t\t\tselect_item.id = fromAllColumn.id;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif ( Global.isSet( tmp_select_items ) ) {\n\t\t\t\t\t\t\t\t\ttmp_select_items.push( fromAllColumn );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif ( !tree_mode ) {\n\t\t\t\t\t\t\t\t\tall_columns.splice( j, 1 );\n\t\t\t\t\t\t\t\t\tall_columns_len = all_columns_len - 1;\n\t\t\t\t\t\t\t\t\tj = j - 1;\n\t\t\t\t\t\t\t\t}\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\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t\t// for all static options, that don't need get reald data, the length should always be match, use temp array because val don't\n\t\t\t//contains full info.\n\t\t\tif ( tmp_select_items && tmp_select_items.length === val.length ||\n\t\t\t\t( val.length > 0 && !val[0].hasOwnProperty( key ) ) ) {\n\t\t\t\tval = tmp_select_items;\n\t\t\t}\n//\t\t\tval = ( Global.isSet( tmp_select_items ) ) ? tmp_select_items : val;\n\n\t\t\t//don't refresh select grid if it's calling from onDropDownsearch whcih doing search in search input\n\t\t\tif ( !searchResult ) {\n\t\t\t\t//select_grid.clearGridData();\n\t\t\t\t//FIXES BUG #1998: The api call returns true when the data it's looking for is deleted. This causes the grid to add a blank row to the unselected side when clear is clicked.\n\t\t\t\tif ( typeof val === 'object' ) {\n\t\t\t\t\tselect_grid.setData( val );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( !tree_mode ) {\n\t\t\t\tunselect_grid.setData( all_columns );\n\t\t\t\tthis.setTotalDisplaySpan();\n\t\t\t} else {\n\t\t\t\ta_dropdown_this.reSetUnSelectGridTreeData( all_columns );\n\t\t\t}\n\t\t\ta_dropdown_this.setSelectGridDragAble();\n\t\t\ta_dropdown_this.setUnSelectGridDragAble();\n\n\t\t};\n\n\t\tthis.setUnSelectGridHighlight = function( array ) {\n\t\t\tunselect_grid.resetSelection();\n\t\t\t$.each( array, function( index, content ) {\n\t\t\t\tunselect_grid.grid.jqGrid( 'setSelection', content, false );\n\t\t\t} );\n\n\t\t};\n\n\t\tthis.showNoResultCover = function( target_grid ) {\n\n\t\t\tthis.removeNoResultCover( target_grid );\n\n\t\t\tvar no_result_box = Global.loadWidgetByName( WidgetNamesDic.NO_RESULT_BOX );\n\t\t\tno_result_box.NoResultBox( { related_view_controller: this } );\n\t\t\tvar grid_div;\n\n\t\t\tif ( target_grid === 'unselect_grid' ) {\n\t\t\t\tno_result_box.attr( 'id', id + target_grid + '_no_result_box' );\n\n\t\t\t\tgrid_div = $( this ).find( '#gbox_unselect_grid_' + id );\n\n\t\t\t\tunselect_grid_no_result_box = no_result_box;\n\n\t\t\t} else {\n\t\t\t\tno_result_box.attr( 'id', id + target_grid + '_no_result_box' );\n\n\t\t\t\tgrid_div = $( this ).find( '#gbox_select_grid_' + id );\n\n\t\t\t\tselect_grid_no_result_box = no_result_box;\n\n\t\t\t}\n\n\t\t\tgrid_div.append( no_result_box );\n\n\t\t};\n\n\t\tthis.removeNoResultCover = function( target_grid ) {\n\t\t\tif ( target_grid === 'unselect_grid' ) {\n\n\t\t\t\tif ( unselect_grid_no_result_box ) {\n\t\t\t\t\tunselect_grid_no_result_box.remove();\n\t\t\t\t\tunselect_grid_no_result_box = null;\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tif ( select_grid_no_result_box ) {\n\t\t\t\t\tselect_grid_no_result_box.remove();\n\t\t\t\t\tselect_grid_no_result_box = null;\n\t\t\t\t}\n\n\t\t\t}\n\t\t};\n\n\t\tthis.setSelectGridHighlight = function( array ) {\n\t\t\tselect_grid.resetSelection();\n\t\t\t$.each( array, function( index, content ) {\n\t\t\t\tselect_grid.grid.jqGrid( 'setSelection', content, false );\n\t\t\t} );\n\n\t\t};\n\n\t\tthis.setUnSelectGridDragAble = function() {\n\n\t\t\tvar highlight_Rows = null;\n\n\t\t\tvar trs = unselect_grid.grid.find( 'tr.ui-widget-content' ).attr( 'draggable', 'true' );\n\n\t\t\ttrs.unbind( 'dragstart' ).bind( 'dragstart', function( event ) {\n\t\t\t\tvar target = $( event.target );\n\n\t\t\t\tvar container = $( '<table class=\\'drag-holder-table\\'></table>' );\n\t\t\t\thighlight_Rows = unselect_grid.grid.find( 'tr.ui-state-highlight' );\n\t\t\t\tvar cloneRows = [];\n\t\t\t\tvar len = highlight_Rows.length;\n\t\t\t\tif ( len === 0 ) {\n\t\t\t\t\tlen = 1;\n\t\t\t\t\tunselect_grid.grid.jqGrid( 'setSelection', target.attr( 'id' ), false );\n\t\t\t\t} else if ( !target.hasClass( 'ui-state-highlight' ) ) {\n\t\t\t\t\tselectAllInGrid( unselect_grid, true );\n\t\t\t\t\tunselect_grid.grid.jqGrid( 'setSelection', target.attr( 'id' ), false );\n\t\t\t\t\tlen = 1;\n\t\t\t\t}\n\n\t\t\t\tif ( len === 1 ) {\n\t\t\t\t\thighlight_Rows = unselect_grid.grid.find( 'tr.ui-state-highlight' );\n\t\t\t\t\tvar clone_row = $( highlight_Rows[0] ).clone();\n\n\t\t\t\t\tclone_row.children().eq( 0 ).remove();\n\t\t\t\t\tclone_row.find( 'td' ).css( 'padding-right', 10 );\n\t\t\t\t\tclone_row.find( 'td' ).css( 'padding-left', 10 );\n\n\t\t\t\t\tcontainer.append( clone_row );\n\t\t\t\t} else {\n\t\t\t\t\tcontainer.append( len + ' ' + $.i18n._( 'item(s) selected' ) );\n\t\t\t\t}\n\n\t\t\t\t$( 'body' ).find( '.drag-holder-table' ).remove();\n\n\t\t\t\t$( 'body' ).append( container );\n\n\t\t\t\tevent.originalEvent.dataTransfer.setData( 'Text', 'un_select_grid' );//JUST ELEMENT references is ok here NO ID\n\n\t\t\t\tif ( event.originalEvent.dataTransfer.setDragImage ) {\n\t\t\t\t\tevent.originalEvent.dataTransfer.setDragImage( container[0], -10, 0 );\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t} );\n\n\t\t\tunselect_grid.grid.parent().parent().unbind( 'dragover' ).bind( 'dragover', function( event ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t} );\n\n\t\t\tunselect_grid.grid.parent().parent().unbind( 'drop' ).bind( 'drop', function( event ) {\n\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( event.stopPropagation ) {\n\t\t\t\t\tevent.stopPropagation(); // stops the browser from redirecting.\n\t\t\t\t}\n\t\t\t\t$( '.drag-holder-table' ).remove();\n\t\t\t\t//drag from left to right\n\t\t\t\tif ( event.originalEvent.dataTransfer.getData( 'Text' ) === 'select_grid' ) {\n\t\t\t\t\tvar grid_selected_id_array = select_grid.grid.jqGrid( 'getGridParam', 'selarrrow' );\n\t\t\t\t\tvar grid_selected_length = grid_selected_id_array.length;\n\n\t\t\t\t\tif ( grid_selected_length > 0 ) {\n\t\t\t\t\t\ta_dropdown_this.moveItems( false, grid_selected_id_array );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\ttrs.unbind( 'dragend' ).bind( 'dragend', function( event ) {\n\t\t\t\t$( '.drag-holder-table' ).remove();\n\t\t\t} );\n\n\t\t\tunselect_grid.grid.parent().parent().unbind( 'dragend' ).bind( 'dragend', function( event ) {\n\t\t\t\t$( '.drag-holder-table' ).remove();\n\t\t\t} );\n\n\t\t};\n\n\t\t//Start Drag\n\t\tthis.setSelectGridDragAble = function() {\n\n\t\t\tvar highlight_Rows = null;\n\t\t\tvar $$this = this;\n\n\t\t\tvar trs = select_grid.grid.find( 'tr.ui-widget-content' ).attr( 'draggable', 'true' );\n\n\t\t\ttrs.attr( 'draggable', true );\n\n\t\t\ttrs.unbind( 'dragstart' ).bind( 'dragstart', function( event ) {\n\t\t\t\tvar target = $( event.target );\n\t\t\t\tvar container = $( '<table class=\\'drag-holder-table\\' from=\\'select_grid\\'></table>' );\n\t\t\t\thighlight_Rows = select_grid.grid.find( 'tr.ui-state-highlight' );\n\t\t\t\tvar cloneRows = [];\n\t\t\t\tvar len = highlight_Rows.length;\n\n\t\t\t\tif ( len === 0 ) {\n\t\t\t\t\tlen = 1;\n\t\t\t\t\tselect_grid.grid.jqGrid( 'setSelection', target.attr( 'id' ), false );\n\t\t\t\t} else if ( !target.hasClass( 'ui-state-highlight' ) ) {\n\t\t\t\t\tselectAllInGrid( select_grid, true );\n\t\t\t\t\tselect_grid.grid.jqGrid( 'setSelection', target.attr( 'id' ), false );\n\t\t\t\t\tlen = 1;\n\t\t\t\t}\n\n\t\t\t\tif ( len === 1 ) {\n\t\t\t\t\thighlight_Rows = select_grid.grid.find( 'tr.ui-state-highlight' );\n\n\t\t\t\t\tvar clone_row = $( highlight_Rows[0] ).clone();\n\n\t\t\t\t\tclone_row.children().eq( 0 ).remove();\n\t\t\t\t\tclone_row.find( 'td' ).css( 'padding-right', 10 );\n\t\t\t\t\tclone_row.find( 'td' ).css( 'padding-left', 10 );\n\n\t\t\t\t\tcontainer.append( clone_row );\n\t\t\t\t} else {\n\t\t\t\t\tcontainer.append( len + ' ' + $.i18n._( 'item(s) selected' ) );\n\t\t\t\t}\n\n\t\t\t\t$( '.drag-holder-table' ).remove();\n\n\t\t\t\t$( 'body' ).append( container );\n\n\t\t\t\tevent.originalEvent.dataTransfer.setData( 'Text', 'select_grid' );//JUST ELEMENT references is ok here NO ID\n\n\t\t\t\tif ( event.originalEvent.dataTransfer.setDragImage ) {\n\t\t\t\t\tevent.originalEvent.dataTransfer.setDragImage( container[0], -10, 0 );\n\t\t\t\t}\n\t\t\t\treturn true;\n\n\t\t\t} );\n\n\t\t\tselect_grid.grid.parent().parent().unbind( 'dragover' ).bind( 'dragover', function( event ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t} );\n\n\t\t\tselect_grid.grid.parent().parent().unbind( 'drop' ).bind( 'drop', function( event ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( event.stopPropagation ) {\n\t\t\t\t\tevent.stopPropagation(); // stops the browser from redirecting.\n\t\t\t\t}\n\t\t\t\t$( '.drag-holder-table' ).remove();\n\t\t\t\t//drag from left to right\n\t\t\t\tif ( event.originalEvent.dataTransfer.getData( 'Text' ) === 'un_select_grid' ) {\n\t\t\t\t\tif ( !tree_mode ) {\n\t\t\t\t\t\tvar grid_selected_id_array = unselect_grid.grid.jqGrid( 'getGridParam', 'selarrrow' );\n\t\t\t\t\t\tvar grid_selected_length = grid_selected_id_array.length;\n\t\t\t\t\t\tif ( grid_selected_length > 0 ) {\n\t\t\t\t\t\t\ta_dropdown_this.moveItems( true, grid_selected_id_array );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvar selectRow = unselect_grid.grid.jqGrid( 'getGridParam', 'selrow' );\n\t\t\t\t\t\ta_dropdown_this.moveItems( true, [selectRow] );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t\t//when drag item to the header row, put them as first row\n\t\t\tvar parent_grid_container = select_grid.grid.parent().parent().parent();\n\t\t\tparent_grid_container = parent_grid_container.find( '.ui-jqgrid-labels' );\n\n\t\t\tparent_grid_container.unbind( 'dragover' ).bind( 'dragover', function( event ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t$( this ).addClass( 'drag-over-bottom' );\n\t\t\t} );\n\n\t\t\tparent_grid_container.unbind( 'dragleave' ).bind( 'dragleave', function( event ) {\n\t\t\t\t$( this ).removeClass( 'drag-over-bottom' );\n\n\t\t\t} );\n\n\t\t\ttrs.unbind( 'dragend' ).bind( 'dragend', function( event ) {\n\t\t\t\t$( '.drag-holder-table' ).remove();\n\t\t\t} );\n\n\t\t\tselect_grid.grid.parent().parent().unbind( 'dragend' ).bind( 'dragend', function( event ) {\n\t\t\t\t$( '.drag-holder-table' ).remove();\n\t\t\t} );\n\n\t\t\tparent_grid_container.unbind( 'dragend' ).bind( 'dragend', function( event ) {\n\t\t\t\t$( '.drag-holder-table' ).remove();\n\t\t\t} );\n\n\t\t\t//when dropping on th/divs at top of grid.\n\t\t\tparent_grid_container.unbind( 'drop' ).bind( 'drop', function( event ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( event.stopPropagation ) {\n\t\t\t\t\tevent.stopPropagation(); // stops the browser from redirecting.\n\t\t\t\t}\n\n\t\t\t\t$( '.drag-holder-table' ).remove();\n\t\t\t\t$( this ).removeClass( 'drag-over-bottom' );\n\t\t\t\tif ( event.originalEvent.dataTransfer.getData( 'Text' ) === 'select_grid' ) {\n\n\t\t\t\t\tvar firstTr = select_grid.grid.find( 'tr.ui-widget-content' )[0];\n\t\t\t\t\tif ( !firstTr ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tvar rows = select_grid.grid.find( 'tr.ui-state-highlight' );\n\n\t\t\t\t\tvar len = rows.length;\n\n\t\t\t\t\tfor ( var i = len - 1; i >= 0; i-- ) {\n\n\t\t\t\t\t\tvar value = rows[i];\n\t\t\t\t\t\tvar row = $( value );\n\n\t\t\t\t\t\tvar target_row_index = 0;\n\t\t\t\t\t\tvar select_items = a_dropdown_this.getSelectItems();\n\t\t\t\t\t\tvar drag_item_index = value.rowIndex - 1;\n\n\t\t\t\t\t\tselect_items.splice( target_row_index, 0, select_items.splice( drag_item_index, 1 )[0] );\n\n\t\t\t\t\t\t$( row ).insertAfter( firstTr ); // insert after sizerow.\n\t\t\t\t\t}\n\n\t\t\t\t\tvar scroll_position = select_grid.grid.parents( '.ui-jqgrid-bdiv' ).scrollTop();\n\t\t\t\t\tisChanged = true;\n\t\t\t\t\tselect_grid.grid.trigger( 'reloadGrid' );\n\n\t\t\t\t\t$$this.setSelectGridDragAble();\n\n\t\t\t\t\trows = select_grid.grid.find( 'tr.ui-widget-content' );\n\n\t\t\t\t\t$.each( highlight_Rows, function( index, value ) {\n\n\t\t\t\t\t\tvar item = value;\n\t\t\t\t\t\tvar itemLabel = $( item ).find( 'td' )[1].innerHTML;\n\n\t\t\t\t\t\t$.each( rows, function( index1, value1 ) {\n\t\t\t\t\t\t\tvar row = value1;\n\n\t\t\t\t\t\t\tvar rowLabel = $( row ).find( 'td' )[1].innerHTML;\n\t\t\t\t\t\t\tif ( itemLabel === rowLabel ) {\n\t\t\t\t\t\t\t\tselect_grid.grid.jqGrid( 'setSelection', $( row ).attr( 'id' ), false );\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\n\t\t\t\t\t} );\n\n\t\t\t\t\tselect_grid.grid.parents( '.ui-jqgrid-bdiv' ).scrollTop( scroll_position );\n\t\t\t\t} else if ( event.originalEvent.dataTransfer.getData( 'Text' ) === 'un_select_grid' ) {\n\t\t\t\t\ttarget_row_index = -1;\n\t\t\t\t\tvar grid_selected_id_array = unselect_grid.grid.jqGrid( 'getGridParam', 'selarrrow' );\n\t\t\t\t\tvar grid_selected_length = grid_selected_id_array.length;\n\t\t\t\t\tif ( grid_selected_length > 0 ) {\n\t\t\t\t\t\ta_dropdown_this.moveItems( true, grid_selected_id_array, target_row_index );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ta_dropdown_this.trigger( 'formItemChange', [a_dropdown_this] );\n\n\t\t\t} );\n\n\t\t\ttrs.unbind( 'dragover' ).bind( 'dragover', function( event ) {\n\t\t\t\t$( this ).addClass( 'drag-over-bottom' );\n\t\t\t} );\n\n\t\t\ttrs.unbind( 'dragleave' ).bind( 'dragleave', function( event ) {\n\t\t\t\t$( this ).removeClass( 'drag-over-bottom' );\n\t\t\t} );\n\n\t\t\ttrs.unbind( 'drop' ).bind( 'drop', function( event ) {\n\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( event.stopPropagation ) {\n\t\t\t\t\tevent.stopPropagation(); // stops the browser from redirecting.\n\t\t\t\t}\n\n\t\t\t\t$( this ).removeClass( 'drag-over-bottom' );\n\n\t\t\t\tvar $this = this;\n\t\t\t\t// Dont do drag to order\n\t\t\t\tif ( event.originalEvent.dataTransfer.getData( 'Text' ) === 'select_grid' ) {\n\t\t\t\t\tvar rows = select_grid.grid.find( 'tr.ui-state-highlight' );\n\n\t\t\t\t\tvar len = rows.length;\n\n\t\t\t\t\tfor ( var i = len - 1; i >= 0; i-- ) {\n\n\t\t\t\t\t\tvar value = rows[i];\n\t\t\t\t\t\tvar row = $( value );\n\n\t\t\t\t\t\tif ( value === this ) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvar target_row_index = $this.rowIndex - 1;\n\t\t\t\t\t\tvar select_items = a_dropdown_this.getSelectItems();\n\t\t\t\t\t\tvar drag_item_index = value.rowIndex - 1;\n\n\t\t\t\t\t\tif ( target_row_index >= drag_item_index ) {\n\t\t\t\t\t\t\tselect_items.splice( target_row_index, 0, select_items.splice( drag_item_index, 1 )[0] );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselect_items.splice( target_row_index + 1, 0, select_items.splice( drag_item_index, 1 )[0] );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t$( row ).insertAfter( $this );\n\t\t\t\t\t}\n\t\t\t\t\tisChanged = true;\n\t\t\t\t\tvar scroll_position = select_grid.grid.closest( '.ui-jqgrid-bdiv' ).scrollTop();\n\t\t\t\t\tselect_grid.grid.trigger( 'reloadGrid' );\n\n\t\t\t\t\t$$this.setSelectGridDragAble();\n\n\t\t\t\t\trows = select_grid.grid.find( 'tr.ui-widget-content' );\n\n\t\t\t\t\t$.each( highlight_Rows, function( index, value ) {\n\n\t\t\t\t\t\tvar item = value;\n\t\t\t\t\t\tvar itemLabel = $( item ).find( 'td' )[1].innerHTML;\n\n\t\t\t\t\t\t$.each( rows, function( index1, value1 ) {\n\t\t\t\t\t\t\trow = value1;\n\n\t\t\t\t\t\t\tvar rowLabel = $( row ).find( 'td' )[1].innerHTML;\n\t\t\t\t\t\t\tif ( itemLabel === rowLabel ) {\n\t\t\t\t\t\t\t\tselect_grid.grid.jqGrid( 'setSelection', $( row ).attr( 'id' ), false );\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\n\t\t\t\t\t} );\n\n\t\t\t\t\tselect_grid.grid.closest( '.ui-jqgrid-bdiv' ).scrollTop( scroll_position );\n\t\t\t\t} else if ( event.originalEvent.dataTransfer.getData( 'Text' ) === 'un_select_grid' ) {\n\n\t\t\t\t\tif ( !tree_mode ) {\n\t\t\t\t\t\ttarget_row_index = $this.rowIndex - 1;\n\t\t\t\t\t\tvar grid_selected_id_array = unselect_grid.grid.jqGrid( 'getGridParam', 'selarrrow' );\n\t\t\t\t\t\tvar grid_selected_length = grid_selected_id_array.length;\n\t\t\t\t\t\tif ( grid_selected_length > 0 ) {\n\t\t\t\t\t\t\ta_dropdown_this.moveItems( true, grid_selected_id_array, target_row_index, $( $this ).attr( 'id' ) );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvar selectRow = unselect_grid.grid.jqGrid( 'getGridParam', 'selrow' );\n\t\t\t\t\t\ta_dropdown_this.moveItems( true, [selectRow] );\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\t//Need to dirty the form when changing order of selected items\n\t\t\t\ta_dropdown_this.trigger( 'formItemChange', [a_dropdown_this] );\n\t\t\t} );\n\t\t};\n\n\t\tthis.setTotalDisplaySpan = function() {\n\t\t\tvar grid_selected_id_array;\n\n\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\tgrid_selected_id_array = unselect_grid.grid.jqGrid( 'getGridParam', 'selarrrow' );\n\t\t\t} else {\n\t\t\t\tgrid_selected_id_array = unselect_grid.grid.jqGrid( 'getGridParam', 'selrow' ) ? [unselect_grid.grid.jqGrid( 'getGridParam', 'selrow' )] : [];\n\t\t\t}\n\n\t\t\tvar grid_selected_length = 0;\n\t\t\t//Uncaught TypeError: Cannot read property 'length' of undefined\n\t\t\tif ( grid_selected_id_array ) {\n\t\t\t\tgrid_selected_length = grid_selected_id_array.length;\n\t\t\t}\n\n\t\t\tvar totalRows = 0;\n\t\t\tvar start = 0;\n\t\t\tvar end = 0;\n\t\t\tvar unselect_grid_length = ( ( unselect_grid && Global.isArray( unselect_grid.getGridParam( 'data' ) ) ) ? unselect_grid.getGridParam( 'data' ).length : 0 );\n\n\t\t\t// CLICK TO SHOW MORE MODE OR SHOW ALL\n\t\t\tif ( LocalCacheData.paging_type === 0 || !pager_data || ( pager_data && pager_data.last_page_number < 0 ) ) {\n\t\t\t\tif ( pager_data ) {\n\t\t\t\t\ttotalRows = pager_data.total_rows;\n\t\t\t\t\tstart = 1;\n\t\t\t\t\tend = unselect_grid_length;\n\t\t\t\t} else {\n\t\t\t\t\ttotalRows = unselect_grid_length;\n\t\t\t\t\tstart = 1;\n\t\t\t\t\tend = unselect_grid_length;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( pager_data ) {\n\t\t\t\t\ttotalRows = pager_data.total_rows;\n\t\t\t\t\tstart = 0;\n\t\t\t\t\tend = 0;\n\n\t\t\t\t\tif ( pager_data.last_page_number > 1 ) {\n\t\t\t\t\t\tif ( !pager_data.is_last_page ) {\n\t\t\t\t\t\t\tstart = ( pager_data.current_page - 1 ) * pager_data.rows_per_page + 1;\n\t\t\t\t\t\t\tend = start + pager_data.rows_per_page - 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tstart = totalRows - unselect_grid_length + 1;\n\t\t\t\t\t\t\tend = totalRows;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstart = 1;\n\t\t\t\t\t\tend = totalRows;\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\ttotalRows = 0;\n\t\t\t\t\tstart = 0;\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar totalInfo;\n\t\t\tif ( allow_multiple_selection ) {\n\n\t\t\t\tvar selected_count = this.getSelectItems().length;\n\n\t\t\t\tvar remain_count = unselect_grid_length;\n\n\t\t\t\tif ( remain_count === 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t\tstart = 0;\n\t\t\t\t} else {\n\t\t\t\t\tend = ( remain_count + start );\n\t\t\t\t\tif ( start === 1 ) {\n\t\t\t\t\t\tend = end - 1;\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( totalRows ) {\n\n\t\t\t\t\t//If there is manually added item\n\t\t\t\t\tif ( end > totalRows ) {\n\t\t\t\t\t\ttotalRows = end;\n\t\t\t\t\t}\n\n\t\t\t\t\ttotalInfo = start + ' - ' + end + ' ' + $.i18n._( 'of' ) + ' ' + totalRows + ' ' + $.i18n._( 'total' ) + '. ';\n\n\t\t\t\t} else {\n\t\t\t\t\ttotalInfo = start + ' - ' + end + '.';\n\t\t\t\t}\n\n\t\t\t\ttotal_display_span.text( $.i18n._( 'Displaying' ) + ' ' + totalInfo + ' ' + $.i18n._( 'Selected' ) + ': ' + selected_count );\n\n\t\t\t} else {\n\n\t\t\t\tif ( end === 0 ) {\n\t\t\t\t\tstart = 0;\n\t\t\t\t}\n\t\t\t\tif ( totalRows ) {\n\n\t\t\t\t\t//If there is manually added item\n\t\t\t\t\tif ( end > totalRows ) {\n\t\t\t\t\t\ttotalRows = end;\n\t\t\t\t\t}\n\n\t\t\t\t\ttotalInfo = start + ' - ' + end + ' ' + $.i18n._( 'of' ) + ' ' + totalRows + ' ' + $.i18n._( 'total' ) + '. ';\n\t\t\t\t} else {\n\t\t\t\t\ttotalInfo = start + ' - ' + end + '.';\n\t\t\t\t}\n\n\t\t\t\ttotal_display_span.text( $.i18n._( 'Displaying' ) + ' ' + totalInfo );\n\t\t\t}\n\n\t\t};\n\n\t\tthis.onUnSelectGridSelectRow = function() {\n\t\t\tthis.setTotalDisplaySpan();\n\t\t};\n\n\t\tthis.onUnSelectGridDoubleClick = function() {\n\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\tif ( !tree_mode ) {\n\t\t\t\t\tvar grid_selected_id_array = unselect_grid.grid.jqGrid( 'getGridParam', 'selarrrow' );\n\t\t\t\t\tvar grid_selected_length = grid_selected_id_array.length;\n\t\t\t\t\tif ( grid_selected_length > 0 ) {\n\t\t\t\t\t\ta_dropdown_this.moveItems( true, grid_selected_id_array );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tvar selectRow = unselect_grid.grid.jqGrid( 'getGridParam', 'selrow' );\n\t\t\t\t\ta_dropdown_this.moveItems( true, [selectRow] );\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tthis.onSelectGridDoubleClick = function() {\n\t\t\tvar grid_selected_id_array = select_grid.grid.jqGrid( 'getGridParam', 'selarrrow' );\n\t\t\tvar grid_selected_length = grid_selected_id_array.length;\n\n\t\t\tif ( grid_selected_length > 0 ) {\n\t\t\t\ta_dropdown_this.moveItems( false, grid_selected_id_array );\n\t\t\t}\n\n\t\t};\n\n\t\t//Move items between 2 grids\n\t\tthis.moveItems = function( left_to_right, array, index, target_row_id ) {\n\t\t\tthis.removeNoResultCover( 'unselect_grid' );\n\t\t\tthis.removeNoResultCover( 'select_grid' );\n\t\t\tvar added_items = [];\n\t\t\tvar removed_items = [];\n\t\t\tisChanged = true;\n\n\t\t\tvar editable_unselect_items = $( unselect_grid.grid ).find( '.editable' );\n\t\t\tfor ( var i = 0; i < editable_unselect_items.length; i++ ) {\n\t\t\t\tvar $el = $( editable_unselect_items[i] );\n\t\t\t\tvar tr_id = $el.parents( 'tr' ).prop( 'id' );\n\t\t\t\tunselect_grid.grid.saveRow( tr_id );\n\t\t\t}\n\n\t\t\tvar editable_select_items = $( select_grid.grid ).find( '.editable' );\n\t\t\tfor ( var i = 0; i < editable_select_items.length; i++ ) {\n\t\t\t\tvar $el = $( editable_select_items[i] );\n\t\t\t\tvar tr_id = $el.parents( 'tr' ).prop( 'id' );\n\t\t\t\tselect_grid.grid.saveRow( tr_id );\n\t\t\t}\n\n\t\t\tvar moved_items_array = array.slice();\n\n\t\t\tif ( left_to_right ) {\n\t\t\t\tvar source_grid = unselect_grid;\n\t\t\t\tvar target_grid = select_grid;\n\t\t\t\tvar source_data = unselect_grid.getGridParam( 'data' );\n\t\t\t\tvar target_data = select_grid.getGridParam( 'data' );\n\t\t\t} else {\n\t\t\t\tsource_grid = select_grid;\n\t\t\t\ttarget_grid = unselect_grid;\n\t\t\t\tsource_data = select_grid.getGridParam( 'data' );\n\t\t\t\ttarget_data = unselect_grid.getGridParam( 'data' );\n\t\t\t}\n\n\t\t\tif ( !Global.isArray( target_data ) ) {\n\t\t\t\ttarget_data = [];\n\t\t\t}\n\n\t\t\tif ( source_data[0] && source_data[0].hasOwnProperty( 'id' ) ) {\n\t\t\t\tif ( !Global.isSet( index ) ) {\n\t\t\t\t\tarray = array.reverse();\n\t\t\t\t}\n\n\t\t\t\tfor ( var i = array.length - 1; i >= 0; i-- ) {\n\t\t\t\t\tvar selected_item_id = array[i];\n\n\t\t\t\t\tfor ( var j = 0; j < source_data.length; j++ ) {\n\t\t\t\t\t\tvar from_all_columns_item = source_data[j];\n\t\t\t\t\t\tif ( from_all_columns_item.hidden ) {\n\t\t\t\t\t\t\tcontinue; //Do not move hidden iteme\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( from_all_columns_item.id == selected_item_id ) { //html number is string, compare string numbers with number number\n\t\t\t\t\t\t\tvar select_item = from_all_columns_item;\n\n\t\t\t\t\t\t\tif ( !tree_mode || !left_to_right ) { //Don't remove item from list if tree mode\n\t\t\t\t\t\t\t\tsource_grid.grid.jqGrid( 'delRowData', selected_item_id );\n\t\t\t\t\t\t\t\ti = i + 1;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( !tree_mode || left_to_right ) {\n\t\t\t\t\t\t\t\tif ( tree_mode ) {\n\t\t\t\t\t\t\t\t\t//Make sure only one item can be add to right when tree mode\n\t\t\t\t\t\t\t\t\tvar target_data_len = target_data.length;\n\t\t\t\t\t\t\t\t\tvar find = false;\n\t\t\t\t\t\t\t\t\tfor ( var y = 0; y < target_data_len; y++ ) {\n\t\t\t\t\t\t\t\t\t\tvar existed_item = target_data[y];\n\t\t\t\t\t\t\t\t\t\tif ( existed_item[key] === select_item[key] ) {\n\t\t\t\t\t\t\t\t\t\t\tfind = true;\n\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tif ( !find ) {\n\n\t\t\t\t\t\t\t\t\t\tif ( index >= 0 ) {\n\t\t\t\t\t\t\t\t\t\t\ttarget_grid.grid.addRowData( selected_item_id, select_item, 'after', target_row_id );\n\t\t\t\t\t\t\t\t\t\t\ttarget_data.splice( target_data.length - 1, 1 );\n\t\t\t\t\t\t\t\t\t\t\ttarget_data.splice( index + 1, 0, select_item );\n\n\t\t\t\t\t\t\t\t\t\t} else if ( index === -1 ) { // add to first row\n\t\t\t\t\t\t\t\t\t\t\ttarget_grid.grid.addRowData( selected_item_id, select_item, 'first' );\n\t\t\t\t\t\t\t\t\t\t\ttarget_data.splice( target_data.length - 1, 1 );\n\t\t\t\t\t\t\t\t\t\t\ttarget_data.unshift( select_item );\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\ttarget_grid.grid.addRowData( selected_item_id, select_item );\n\t\t\t\t\t\t\t\t\t\t\ttarget_data[target_data.length - 1] = select_item; //need this since we need full data, addRowData only keep data which shown on UI\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\tif ( index >= 0 ) {\n\t\t\t\t\t\t\t\t\t\ttarget_grid.grid.addRowData( selected_item_id, select_item, 'after', target_row_id );\n\t\t\t\t\t\t\t\t\t\ttarget_data.splice( target_data.length - 1, 1 );\n\t\t\t\t\t\t\t\t\t\ttarget_data.splice( index + 1, 0, select_item );\n\n\t\t\t\t\t\t\t\t\t} else if ( index === -1 ) { // add to first row\n\t\t\t\t\t\t\t\t\t\ttarget_grid.grid.addRowData( selected_item_id, select_item, 'first' );\n\t\t\t\t\t\t\t\t\t\ttarget_data.splice( target_data.length - 1, 1 );\n\t\t\t\t\t\t\t\t\t\ttarget_data.unshift( select_item );\n\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\ttarget_grid.grid.addRowData( selected_item_id, select_item );\n\t\t\t\t\t\t\t\t\t\ttarget_data[target_data.length - 1] = select_item; //\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tadded_items.push( select_item );\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\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\t\t\t}\n\n\t\t\tif ( !tree_mode ) {\n\t\t\t\ttarget_grid.grid.trigger( 'reloadGrid' );\n\t\t\t\t// if ( left_to_right ) {\n\t\t\t\t// \ta_dropdown_this.resizeSelectSearchInputs();\n\t\t\t\t// }\n\t\t\t} else {\n\t\t\t\tif ( left_to_right ) {\n\t\t\t\t\ta_dropdown_this.reSetUnSelectGridTreeData( source_data );\n\t\t\t\t} else {\n\t\t\t\t\ta_dropdown_this.reSetUnSelectGridTreeData( target_data );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ta_dropdown_this.setSelectGridDragAble();\n\t\t\ta_dropdown_this.setUnSelectGridDragAble();\n\t\t\ta_dropdown_this.updateRealSelectItemsIfNecessary( left_to_right, moved_items_array );\n\t\t\ta_dropdown_this.setTotalDisplaySpan();\n\n\t\t\tif ( !parent_a_combo_box ) {\n\t\t\t\ta_dropdown_this.trigger( 'formItemChange', [a_dropdown_this] );\n\t\t\t}\n\n\t\t\tif ( a_dropdown_this.isLocalSearchMode() ) {\n\t\t\t\ta_dropdown_this.localSearch( 'unselect', unselect_grid_search_map, added_items );\n\t\t\t\ta_dropdown_this.localSearch( 'select', select_grid_search_map, added_items );\n\t\t\t}\n\t\t};\n\n\t\tthis.updateRealSelectItemsIfNecessary = function( left_to_right, moved_items ) {\n\t\t\tif ( !real_selected_items || real_selected_items.length == 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( left_to_right ) {\n\t\t\t\tvar current_items_in_selected_grid = select_grid.getGridParam( 'data' );\n\t\t\t\t$.each( moved_items, function( index, value ) {\n\t\t\t\t\t$.each( current_items_in_selected_grid, function( index1, value1 ) {\n\t\t\t\t\t\tif ( value1[key] == value ) { //use == to match '' or number of id\n\t\t\t\t\t\t\treal_selected_items.push( value1 );\n\t\t\t\t\t\t\treturn false;\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\t$.each( moved_items, function( index, value ) {\n\t\t\t\t\t$.each( real_selected_items, function( index1, value1 ) {\n\t\t\t\t\t\tif ( value1[key] == value ) { //use == to match '' or number of id\n\t\t\t\t\t\t\treal_selected_items.splice( index1, 1 );\n\t\t\t\t\t\t\treturn false;\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.setHeight = function( height ) {\n\t\t\tif ( max_height && max_height < height ) {\n\t\t\t\theight = max_height;\n\t\t\t}\n\t\t\tunselect_grid.grid.setGridHeight( height );\n\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\tselect_grid.grid.setGridHeight( height );\n\t\t\t}\n\t\t};\n\n\t\tvar initColumnSettingsBtn = function() {\n\t\t\tvar edit_icon_div = $( a_dropdown_this ).find( '.edit-columnIcon-div' );\n\t\t\tvar edit_icon = $( a_dropdown_this ).find( '.edit_column_icon' );\n\t\t\tif ( !display_column_settings || tree_mode ) {\n\t\t\t\tedit_icon_div.hide();\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\tedit_icon_div.show();\n\t\t\t}\n\n\t\t\tedit_icon_div.css( 'display', 'inline-block' );\n\t\t\tedit_icon.attr( 'src', Global.getRealImagePath( 'images/edit.png' ) );\n\n\t\t\t//OPen Column editor\n\t\t\tedit_icon_div.click( function( e ) {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\n\t\t\t\tif ( !parent_a_combo_box.getEnabled() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tapi.getOptions( column_option_key, {\n\t\t\t\t\tonResult: function( columns_result ) {\n\n\t\t\t\t\t\tcolumn_editor = $( $.fn.ColumnEditor.html_template ); // Unable to use Global.loadWidgetByName as FormItemType did not have ColumnEditor listed, and its only used in one place anyway.\n\t\t\t\t\t\tcolumn_editor.find( '#save_btn' ).text( $.i18n._( 'Save and Close' ) );\n\t\t\t\t\t\tcolumn_editor.find( '#close_btn' ).text( $.i18n._( 'Close' ) );\n\t\t\t\t\t\tcolumn_editor.find( '.rows-per-page' ).text( $.i18n._( 'Rows Per Page' ) );\n\t\t\t\t\t\tcolumn_editor.find( '.choose-layout' ).text( $.i18n._( 'Choose Layout' ) );\n\n\t\t\t\t\t\tcolumn_editor = column_editor.ColumnEditor( { parent_awesome_box: parent_a_combo_box } );\n\n\t\t\t\t\t\tvar columns_result_data = columns_result.getResult();\n\t\t\t\t\t\tparent_a_combo_box.setAllColumns( Global.buildColumnArray( columns_result_data ) );\n\t\t\t\t\t\tparent_a_combo_box.setDisplayColumnsForEditor( parent_a_combo_box.buildDisplayColumnsForEditor() );\n\n\t\t\t\t\t\t//Open Column Editor;\n\t\t\t\t\t\tcolumn_editor.show();\n\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t};\n\n\t\tvar setLabels = function() {\n\t\t\tvar unselected_items_label = a_dropdown_this.find( '#unSelectedItemsLabel' );\n\t\t\tvar un_deselect_all_btn = a_dropdown_this.find( '#unDeselectAllBtn' );\n\t\t\tvar unselect_all_btn = a_dropdown_this.find( '#unselect_all_btn' );\n\t\t\tvar un_clear_btn = a_dropdown_this.find( '#un_clear_btn' );\n\t\t\tvar show_all_check_box_label = a_dropdown_this.find( '#show_all_check_box_label' );\n\n\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\tunselected_items_label.text( $.i18n._( 'UNSELECTED ITEMS' ) );\n\t\t\t} else {\n\t\t\t\tunselected_items_label.text( $.i18n._( 'PLEASE SELECT ITEM' ) );\n\t\t\t}\n\t\t\tun_deselect_all_btn.text( $.i18n._( 'Deselect All' ) );\n\t\t\tunselect_all_btn.text( $.i18n._( 'Select All' ) );\n\t\t\tun_clear_btn.text( $.i18n._( 'Move All' ) );\n\t\t\tshow_all_check_box_label.text( $.i18n._( 'Show All' ) );\n\n\t\t\tvar selectedItemsLabel = a_dropdown_this.find( '#selectedItemsLabel' );\n\t\t\tvar delete_all_btn = a_dropdown_this.find( '#delete_all_btn' );\n\t\t\tvar select_all_btn = a_dropdown_this.find( '#select_all_btn' );\n\t\t\tvar clear_btn = a_dropdown_this.find( '#clear_btn' );\n\n\t\t\tselectedItemsLabel.text( $.i18n._( 'SELECTED ITEMS' ) );\n\t\t\tdelete_all_btn.text( $.i18n._( 'Deselect All' ) );\n\t\t\tselect_all_btn.text( $.i18n._( 'Select All' ) );\n\t\t\tclear_btn.text( $.i18n._( 'Move All' ) );\n\n\t\t};\n\n\t\tthis.selectNextItem = function( e ) {\n\t\t\tvar next_index;\n\t\t\tvar target_grid;\n\t\t\tvar next_select_item;\n\t\t\tif ( 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_this.onUnSelectGridDoubleClick();\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_this.onSelectGridDoubleClick();\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}, 200 );\n\t\t\t\te.preventDefault();\n\t\t\t\tquick_search_typed_keys = quick_search_typed_keys + Global.KEYCODES[e.which];\n\t\t\t\tif ( allow_multiple_selection || tree_mode ) {\n\t\t\t\t\tif ( quick_search_typed_keys ) {\n\t\t\t\t\t\ttarget_grid = a_dropdown_this.getFocusInSeletGrid() ? a_dropdown_this.getSelectGrid() : a_dropdown_this.getUnSelectGrid();\n\t\t\t\t\t\tvar search_index = quick_search_dic[quick_search_typed_keys] ? quick_search_dic[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( 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\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_this.unSelectAll( target_grid.grid, true );\n\n\t\t\t\t\t\tnext_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\t\t\t\t\t\ta_dropdown_this.setSelectItem( next_select_item, target_grid );\n\t\t\t\t\t\tquick_search_dic = {};\n\t\t\t\t\t\tquick_search_dic[quick_search_typed_keys] = search_index + 1;\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\tif ( quick_search_typed_keys ) {\n\t\t\t\t\t\tsearch_index = quick_search_dic[quick_search_typed_keys] ? quick_search_dic[quick_search_typed_keys] : 0;\n\t\t\t\t\t\ttds = $( a_dropdown_this.getUnSelectGrid().find( 'tr' ).find( 'td:first' ).filter( function() {\n\t\t\t\t\t\t\treturn $.text( [this] ).toLowerCase().indexOf( 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\n\t\t\t\t\t\ttd = $( tds[search_index] );\n\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_this.setSelectItem( next_select_item );\n\n\t\t\t\t\t\tquick_search_dic = {};\n\t\t\t\t\t\tquick_search_dic[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\t//For multiple items like .xxx could contains a few widgets.\n\t\t//#2353 removed $.each because it's slower\n\t\tfor ( var i = 0; i < this.length; i++ ) {\n\t\t\tvar obj = $( this[i] ); //#2353 - caching the lookup to speed this part up.\n\t\t\tvar o = $.meta ? $.extend( {}, opts, obj.data() ) : opts;\n\n\t\t\tif ( o.default_height > 150 ) {\n\t\t\t\tdefault_height = o.default_height;\n\t\t\t}\n\n\t\t\tfield = o.field;\n\n\t\t\tif ( o.search_input_filter ) {\n\t\t\t\tunselect_grid_search_map = o.search_input_filter;\n\t\t\t}\n\n\t\t\tif ( o.select_grid_search_input_filter ) {\n\t\t\t\tselect_grid_search_map = o.select_grid_search_input_filter;\n\t\t\t}\n\n\t\t\tif ( o.default_sort_filter ) {\n\t\t\t\tunselect_grid_sort_map = o.default_sort_filter;\n\t\t\t}\n\n\t\t\tif ( o.default_select_grid_sort_filter ) {\n\t\t\t\tselect_grid_sort_map = o.default_select_grid_sort_filter;\n\t\t\t}\n\n\t\t\tif ( o.auto_sort ) {\n\t\t\t\tauto_sort = o.auto_sort;\n\t\t\t}\n\n\t\t\tif ( Global.isSet( 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.column_option_key ) {\n\t\t\t\tcolumn_option_key = o.column_option_key;\n\t\t\t}\n\n\t\t\tif ( o.api ) {\n\t\t\t\tapi = o.api;\n\t\t\t}\n\n\t\t\tif ( o.hasOwnProperty( 'display_column_settings' ) ) {\n\t\t\t\tdisplay_column_settings = o.display_column_settings;\n\t\t\t}\n\n\t\t\tif ( o.resize_grids ) {\n\t\t\t\tresize_grids = o.resize_grids;\n\t\t\t} else {\n\t\t\t\tresize_grids = false;\n\t\t\t}\n\n\t\t\t//Init paging widget\n\n\t\t\tleft_buttons_div = obj.find( '.left-buttons-div' );\n\t\t\tright_buttons_div = obj.find( '.right-buttons-div' );\n\n\t\t\tstart = obj.find( '.start' );\n\t\t\tlast = obj.find( '.last' );\n\t\t\tnext = obj.find( '.next' );\n\t\t\tend = obj.find( '.end' );\n\n\t\t\tstart.text( $.i18n._( 'Start' ) );\n\t\t\tlast.text( $.i18n._( 'Previous' ) );\n\n\t\t\tnext.text( $.i18n._( 'Next' ) );\n\t\t\tend.text( $.i18n._( 'End' ) );\n\n\t\t\tstart.click( function() {\n\t\t\t\tif ( left_buttons_enable ) {\n\t\t\t\t\tparent_a_combo_box.onADropDownSearch( 'unselect_grid', 'start' );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tlast.click( function() {\n\t\t\t\tif ( left_buttons_enable ) {\n\t\t\t\t\tparent_a_combo_box.onADropDownSearch( 'unselect_grid', 'last' );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tnext.click( function() {\n\t\t\t\tif ( right_buttons_enable ) {\n\t\t\t\t\tparent_a_combo_box.onADropDownSearch( 'unselect_grid', 'next' );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tend.click( function() {\n\t\t\t\tif ( right_buttons_enable ) {\n\t\t\t\t\tparent_a_combo_box.onADropDownSearch( 'unselect_grid', 'end' );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tleft_buttons_div.css( 'display', 'none' );\n\t\t\tright_buttons_div.css( 'display', 'none' );\n\n\t\t\tif ( LocalCacheData.paging_type !== 10 ) {\n\t\t\t\t//Click to show more button below the last row\n\t\t\t\tpaging_widget = Global.loadWidgetByName( WidgetNamesDic.PAGING );\n\t\t\t}\n\n\t\t\t//Display 'Displaying XX of xx, Selected: xxx'\n\t\t\ttotal_display_span = obj.find( '.total-number-span' );\n\n\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\ttotal_display_span.text( $.i18n._( 'Displaying' ) + ' 0 ' + $.i18n._( 'of' ) + ' 0 ' + $.i18n._( 'total' ) );\n\t\t\t} else {\n\t\t\t\ttotal_display_span.text( $.i18n._( 'Displaying' ) + ' 0 - 0 ' + $.i18n._( 'of' ) + ' 0 ' + $.i18n._( 'total' ) + '. ' + $.i18n._( 'Selected' ) + ': 0' );\n\t\t\t}\n\n\t\t\tif ( !allow_multiple_selection ) {\n\t\t\t\tvar unselect_grd_border_div = obj.find( '.unselect-grid-border-div' );\n\t\t\t\tunselect_grd_border_div.addClass( 'single-mode-border' );\n\n\t\t\t}\n\n\t\t\tvar unselect_grd_div = obj.find( '.unselect-grid-div' );\n\n\t\t\tunselect_grd_div.bind( 'click', function() {\n\t\t\t\tfocus_in_select_grid = false;\n\n\t\t\t} );\n\n\t\t\tvar select_grid_div = obj.find( '.select-grid-div' );\n\t\t\tvar left_and_right_div = obj.find( '.left-and-right-div' );\n\t\t\tvar unselected_items_label = obj.find( '#unselected_items_label' );\n\t\t\tvar selected_items_label = obj.find( '#selected_items_label' );\n\n\t\t\tselect_grid_div.bind( 'click', function() {\n\t\t\t\tfocus_in_select_grid = true;\n\n\t\t\t} );\n\n\t\t\tif ( !allow_multiple_selection ) {\n\t\t\t\tselect_grid_div.css( 'display', 'none' );\n\t\t\t\tleft_and_right_div.css( 'display', 'none' );\n\t\t\t\tunselected_items_label.text( $.i18n._( 'SELECT AN ITEM' ) );\n\t\t\t} else {\n\t\t\t\tselect_grid_div.css( 'display', 'inline-block' );\n\t\t\t\tleft_and_right_div.css( 'display', 'inline-block' );\n\t\t\t\tunselected_items_label.text( $.i18n._( 'UNSELECTED ITEMS' ) );\n\t\t\t\tselected_items_label.text( $.i18n._( 'SELECTED ITEMS' ) );\n\t\t\t}\n\n\t\t\tif ( Global.isSet( o.allow_drag_to_order ) ) {\n\t\t\t\tallow_drag_to_order = o.allow_drag_to_order;\n\t\t\t}\n\n\t\t\t//Set UI visibility\n\t\t\tif ( o.display_show_all === true ) {\n\n\t\t\t\tvar show_all_check_box = obj.find( '#show_all_check_box' );\n\n\t\t\t\tshow_all_check_box.css( 'display', 'normal' );\n\t\t\t\tobj.find( '#show_all_check_box_label' ).css( 'display', 'normal' );\n\n\t\t\t\tif ( o.show_all === true ) {\n\t\t\t\t\tshow_all_check_box.prop( 'checked', 'true' );\n\t\t\t\t} else {\n\t\t\t\t\tshow_all_check_box.prop( 'checked', undefined );\n\t\t\t\t}\n\n\t\t\t\tobj.find( '#show_all_check_box' ).click( function() {\n\t\t\t\t\tvar show_all_checked = false;\n\t\t\t\t\tif ( show_all_check_box.prop( 'checked' ) === 'checked' || show_all_check_box[0].checked === true ) {\n\t\t\t\t\t\tshow_all_checked = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tparent_a_combo_box.onShowAll( show_all_checked );\n\n\t\t\t\t} );\n\n\t\t\t} else {\n\t\t\t\tobj.find( '#show_all_check_box' ).css( 'display', 'none' );\n\t\t\t\tobj.find( '#show_all_check_box_label' ).css( 'display', 'none' );\n\n\t\t\t}\n\n\t\t\tif ( o.comboBox ) {\n\t\t\t\tparent_a_combo_box = o.comboBox;\n\n\t\t\t\tif ( parent_a_combo_box.allow_multiple_selection ) {\n\t\t\t\t\tobj.css( 'min-Width', 958 );\n\t\t\t\t} else {\n\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tobj.css( 'min-Width', 958 );\n\t\t\t}\n\n\t\t\tid = o.id;\n\n\t\t\tobj.attr( 'id', o.id + 'ADropDown' );\n\n\t\t\tif ( o.max_height ) {\n\t\t\t\tmax_height = o.max_height;\n\t\t\t}\n\n\t\t\tif ( o.static_height ) {\n\t\t\t\tstatic_height = o.static_height;\n\t\t\t\tmax_height = o.static_height;\n\t\t\t}\n\n\t\t\tif ( o.key ) {\n\t\t\t\tkey = o.key;\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//All options set, NOW we init the label and column settings button\n\t\t\tsetLabels();\n\t\t\tinitColumnSettingsBtn();\n\n\t\t\tunselect_grid = obj.find( '.unselect-grid' ); //Must add id for them\n\n\t\t\tunselect_grid.attr( 'id', 'unselect_grid' + '_' + id );\n\t\t\tvar unselect_grid_data = {};\n\t\t\tif ( !tree_mode ) {\n\t\t\t\tunselect_grid_data = {\n\t\t\t\t\twidth: 440,\n\t\t\t\t\t//maxHeight: default_height,\n\t\t\t\t\tonCellSelect: a_dropdown_this.onUnSelectGridSelectRow,\n\t\t\t\t\tondblClickRow: a_dropdown_this.onUnSelectGridDoubleClick,\n\t\t\t\t\tmultiselect: allow_multiple_selection,\n\t\t\t\t\twinMultiSelect: allow_multiple_selection,\n\t\t\t\t\tmultiboxonly: allow_multiple_selection\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tunselect_grid_data = {\n\n\t\t\t\t\twidth: 440,\n\t\t\t\t\t//maxHeight: default_height,\n\t\t\t\t\tsortname: 'id',\n\t\t\t\t\tonCellSelect: a_dropdown_this.onUnSelectGridSelectRow,\n\t\t\t\t\tondblClickRow: a_dropdown_this.onUnSelectGridDoubleClick,\n\t\t\t\t\tmultiselect: allow_multiple_selection,\n\t\t\t\t\twinMultiSelect: allow_multiple_selection,\n\t\t\t\t\tgridview: true,\n\t\t\t\t\ttreeGrid: true,\n\t\t\t\t\ttreeGridModel: 'adjacency',\n\t\t\t\t\ttreedatatype: 'local',\n\t\t\t\t\tExpandColumn: 'name',\n\t\t\t\t\tjsonReader: {\n\t\t\t\t\t\trepeatitems: false,\n\t\t\t\t\t\troot: function( obj ) {\n\t\t\t\t\t\t\treturn obj;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpage: function( obj ) {\n\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttotal: function( obj ) {\n\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\t},\n\t\t\t\t\t\trecords: function( obj ) {\n\t\t\t\t\t\t\treturn obj.length;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( max_height ) {\n\t\t\t\tunselect_grid_data.maxHeight = max_height;\n\t\t\t}\n\n\t\t\tif ( static_height ) {\n\t\t\t\tunselect_grid_data.static_height = static_height;\n\t\t\t}\n\n\t\t\tunselect_grid = new TTGrid( 'unselect_grid' + '_' + id, unselect_grid_data, [] );\n\n\t\t\tselect_grid = obj.find( '.select-grid' );\n\n\t\t\tselect_grid.attr( 'id', 'select_grid' + '_' + id );\n\n\t\t\tselect_grid = new TTGrid( 'select_grid' + '_' + id, {\n\t\t\t\tcontainer_selector: '.select-grid-div',\n\t\t\t\taltRows: true,\n\t\t\t\tdata: [],\n\t\t\t\tdatatype: 'local',\n\t\t\t\tsortable: false,\n\t\t\t\twidth: 440,\n\t\t\t\t//maxHeight: default_height,\n\t\t\t\trowNum: 10000,\n\t\t\t\tcolNames: [],\n\t\t\t\tcolModel: [],\n\t\t\t\tondblClickRow: a_dropdown_this.onSelectGridDoubleClick,\n\t\t\t\tmultiselect: allow_multiple_selection,\n\t\t\t\twinMultiSelect: allow_multiple_selection,\n\t\t\t\tmultiboxonly: true,\n\t\t\t\tviewrecords: true,\n\t\t\t\tonResizeGrid: resize_grids,\n\t\t\t\tmaxHeight: max_height,\n\t\t\t\tstatic_height: static_height ? static_height : null\n\n\t\t\t}, [] );\n\n\t\t\tvar right_arrow = obj.find( '.a-grid-right-arrow' );\n\t\t\tvar left_arrow = obj.find( '.a-grid-left-arrow' );\n\n\t\t\tright_arrow.attr( 'src', Global.getRealImagePath( 'css/global/widgets/awesomebox/images/nav_right.png' ) );\n\t\t\tleft_arrow.attr( 'src', Global.getRealImagePath( 'css/global/widgets/awesomebox/images/nav_left.png' ) );\n\n\t\t\tright_arrow.click( function() {\n\n\t\t\t\tif ( !tree_mode ) {\n\t\t\t\t\tvar grid_selected_id_array = unselect_grid.grid.jqGrid( 'getGridParam', 'selarrrow' );\n\t\t\t\t\tvar grid_selected_length = grid_selected_id_array.length;\n\t\t\t\t\tif ( grid_selected_length > 0 ) {\n\t\t\t\t\t\ta_dropdown_this.moveItems( true, grid_selected_id_array );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tvar selectRow = unselect_grid.grid.jqGrid( 'getGridParam', 'selrow' );\n\t\t\t\t\ta_dropdown_this.moveItems( true, [selectRow] );\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t\tleft_arrow.click( function() {\n\t\t\t\tvar grid_selected_id_array = select_grid.grid.jqGrid( 'getGridParam', 'selarrrow' );\n\t\t\t\tvar grid_selected_length = grid_selected_id_array.length;\n\n\t\t\t\tif ( grid_selected_length > 0 ) {\n\t\t\t\t\ta_dropdown_this.moveItems( false, grid_selected_id_array );\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t\t//Set Action Buttons\n\n\t\t\t//UnSelect grid\n\t\t\tvar unselect_all_btn = obj.find( '#unselect_all_btn' );\n\n\t\t\tunselect_all_btn.click( function() {\n\t\t\t\tselectAllInGrid( unselect_grid );\n\t\t\t} );\n\n\t\t\tvar un_deselect_all_Btn = obj.find( '#unDeselectAllBtn' );\n\n\t\t\tun_deselect_all_Btn.click( function() {\n\t\t\t\tselectAllInGrid( unselect_grid, true );\n\n\t\t\t} );\n\n\t\t\tvar un_clear_btn = obj.find( '#un_clear_btn' );\n\n\t\t\tun_clear_btn.click( function() {\n\t\t\t\tcleanAllInGrid( unselect_grid, true );\n\n\t\t\t} );\n\n\t\t\tif ( tree_mode || !allow_multiple_selection ) {\n\t\t\t\tunselect_all_btn.css( 'display', 'none' );\n\t\t\t\tun_deselect_all_Btn.css( 'display', 'none' );\n\t\t\t\tun_clear_btn.css( 'display', 'none' );\n\t\t\t} else {\n\t\t\t\tunselect_all_btn.css( 'display', 'inline-block' );\n\t\t\t\tun_deselect_all_Btn.css( 'display', 'inline-block' );\n\t\t\t\tun_clear_btn.css( 'display', 'inline-block' );\n\t\t\t}\n\n\t\t\t//Select Grid\n\t\t\tvar select_all_btn = obj.find( '#select_all_btn' );\n\n\t\t\tselect_all_btn.click( function() {\n\t\t\t\tselectAllInGrid( select_grid );\n\n\t\t\t} );\n\n\t\t\tvar delete_all_btn = obj.find( '#delete_all_btn' );\n\n\t\t\tdelete_all_btn.click( function() {\n\t\t\t\tselectAllInGrid( select_grid, true );\n\n\t\t\t} );\n\n\t\t\tvar clear_btn = obj.find( '#clear_btn' );\n\n\t\t\tclear_btn.click( function() {\n\t\t\t\tcleanAllInGrid( select_grid );\n\t\t\t} );\n\n\t\t\tvar select_grid_close_btn = obj.find( '#select_grid_close_btn' );\n\t\t\tvar unselect_grid_close_btn = obj.find( '#unselect_grid_close_btn' );\n\n\t\t\tif ( allow_multiple_selection ) {\n\t\t\t\tunselect_grid_close_btn.css( 'display', 'none' );\n\t\t\t} else {\n\t\t\t\tunselect_grid_close_btn.css( 'display', 'inline-block' );\n\t\t\t\tunselect_grid_close_btn.click( function() {\n\t\t\t\t\ta_dropdown_this.trigger( 'close', [a_dropdown_this] );\n\t\t\t\t} );\n\t\t\t}\n\t\t\tif ( Global.isSet( o.display_close_btn ) && !o.display_close_btn ) {\n\t\t\t\tselect_grid_close_btn.css( 'display', 'none' );\n\t\t\t} else {\n\t\t\t\tselect_grid_close_btn.css( 'display', 'inline-block' );\n\t\t\t\tselect_grid_close_btn.click( function() {\n\t\t\t\t\ta_dropdown_this.trigger( 'close', [a_dropdown_this] );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t//Move all records from target grid to another\n\t\t\tfunction cleanAllInGrid( target, left_to_right ) {\n\n\t\t\t\ta_dropdown_this.removeNoResultCover( 'unselect_grid' );\n\t\t\t\ta_dropdown_this.removeNoResultCover( 'select_grid' );\n\n\t\t\t\tisChanged = true;\n\t\t\t\tvar finalArray = [];\n\t\t\t\tif ( left_to_right ) {\n\t\t\t\t\tvar source_grid = unselect_grid;\n\t\t\t\t\tvar target_grid = select_grid;\n\t\t\t\t\tvar source_data = unselect_grid.getData();\n\t\t\t\t\tvar target_data = select_grid.getData();\n\t\t\t\t} else {\n\t\t\t\t\tsource_grid = select_grid;\n\t\t\t\t\ttarget_grid = unselect_grid;\n\t\t\t\t\tsource_data = select_grid.getData();\n\t\t\t\t\ttarget_data = unselect_grid.getData();\n\t\t\t\t}\n\n\t\t\t\tif ( a_dropdown_this.isLocalSearchMode() ) {\n\t\t\t\t\t//Only move visible items while on local search mode.\n\t\t\t\t\tvar [keep_items, move_items] = _.partition( source_data, ( item ) => {\n\t\t\t\t\t\treturn item.hidden;\n\t\t\t\t\t} );\n\n\t\t\t\t\tsource_grid.setData( keep_items );\n\t\t\t\t\ttarget_grid.setData( target_data.concat( move_items ) );\n\n\t\t\t\t\ta_dropdown_this.localSearch( 'unselect', unselect_grid_search_map, move_items );\n\t\t\t\t\ta_dropdown_this.localSearch( 'select', select_grid_search_map, move_items );\n\t\t\t\t}\n\t\t\t\telse if ( tree_mode ) {\n\t\t\t\t\tsource_grid.clearGridData();\n\t\t\t\t\tsource_grid.grid.trigger( 'reloadGrid' );\n\t\t\t\t\ta_dropdown_this.setTotalDisplaySpan();\n\t\t\t\t\ta_dropdown_this.getUnSelectGrid().grid.find( 'tr' ).removeClass( 'selected-tree-cell' );\n\t\t\t\t} else {\n\t\t\t\t\tfinalArray = target_data.concat( source_data );\n\t\t\t\t\ttarget_grid.setData( finalArray );\n\n\t\t\t\t\t//#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.\n\t\t\t\t\tif ( left_to_right ) {\n\t\t\t\t\t\treal_selected_items = finalArray; // Fixes #2721\n\t\t\t\t\t} else {\n\t\t\t\t\t\treal_selected_items = [];\n\t\t\t\t\t}\n\n\t\t\t\t\tsource_grid.clearGridData();\n\t\t\t\t\tsource_grid.grid.trigger( 'reloadGrid' );\n\t\t\t\t\ta_dropdown_this.setTotalDisplaySpan();\n\t\t\t\t}\n\t\t\t\tif ( !parent_a_combo_box ) {\n\t\t\t\t\ta_dropdown_this.trigger( 'formItemChange', [a_dropdown_this] );\n\t\t\t\t}\n\n\t\t\t\ta_dropdown_this.setSelectGridDragAble();\n\t\t\t\ta_dropdown_this.setUnSelectGridDragAble();\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t};\n\n\t$.fn.ADropDown.defaults = {};\n\t$.fn.ADropDown.html_template = `\n\t<div class=\"a-dropdown\">\n\t\t<div class=\"unselect-grid-div\">\n\t\t\t<div class=\"unselect-grid-title-bar\">\n\t\t\t\t<div class=\"edit-columnIcon-div\">\n\t\t\t\t\t<img class=\"edit_column_icon\">\n\t\t\t\t</div>\n\t\t\t\t<span id=\"unSelectedItemsLabel\" class=\"a-grid-title\"></span>\n\t\t\t\t<button id=\"unselect_grid_close_btn\" class=\"a-grid-close-button\"></button>\n\t\t\t\t<button id=\"unDeselectAllBtn\" class=\"a-grid-button\"></button>\n\t\t\t\t<button id=\"unselect_all_btn\" class=\"a-grid-button\"></button>\n\t\t\t\t<button id=\"un_clear_btn\" class=\"a-grid-button\"></button>\n\t\t\t\t<span id=\"show_all_check_box_label\" class=\"a-grid-checkbox-label\"></span>\n\t\t\t\t<input id=\"show_all_check_box\" type=\"checkbox\" class=\"a-grid-checkbox\" value=\"Show All\">\n\t\t\t</div>\n\t\t\t<div class=\"unselect-grid-border-div\">\n\t\t\t\t<div class=\"unselect-grid-search-div\"></div>\n\t\t\t\t<table class=\"a-grid unselect-grid\" id=\"unselect_grid\"></table>\n\t\t\t</div>\n\t\t\t<div class=\"unselect-grid-bottom-bar\">\n\t\t\t\t<div class=\"left-buttons-div\">\n\t\t\t\t\t<a class=\"double-left-arrow\" title=\"Start\"></a>\n\t\t\t\t\t<span class=\"paging-2-span start\"></span>\n\t\t\t\t\t<a class=\"left-arrow\"></a>\n\t\t\t\t\t<span class=\"paging-2-span last\"></span>\n\t\t\t\t</div>\n\t\t\t\t<span class=\"total-number-span\"></span>\n\t\t\t\t<div class=\"right-buttons-div\">\n\t\t\t\t\t<span class=\"paging-2-span next\"></span>\n\t\t\t\t\t<a class=\"right-arrow\"></a>\n\t\t\t\t\t<span class=\"paging-2-span end\"></span>\n\t\t\t\t\t<a class=\"double-right-arrow\"></a>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t\t<div class=\"left-and-right-div\">\n\t\t\t<div class=\"right-arrow-div\"><img class=\"a-grid-right-arrow\"></div>\n\t\t\t<div class=\"left-arrow-div\"><img class=\"a-grid-left-arrow\"></div>\n\t\t</div>\n\t\t<div class=\"select-grid-div\">\n\t\t\t<div class=\"select-grid-title-bar\">\n\t\t\t\t<span id=\"selectedItemsLabel\" class=\"a-grid-title\"> SELECTED ITEMS</span>\n\t\t\t\t<button id=\"select_grid_close_btn\" class=\"a-grid-close-button\"></button>\n\t\t\t\t<button id=\"delete_all_btn\" class=\"a-grid-button\">Deselect All</button>\n\t\t\t\t<button id=\"select_all_btn\" class=\"a-grid-button\">Select All</button>\n\t\t\t\t<button id=\"clear_btn\" class=\"a-grid-button\">Move All</button>\n\t\t\t</div>\n\t\t\t<div class=\"select-grid-border-div\">\n\t\t\t\t<div class=\"select-grid-search-div\"></div>\n\t\t\t\t<table class=\"a-grid select-grid\" id=\"select_grid\"></table>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t`;\n\n} )( jQuery );\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMzIzNC5qcyIsIm1hcHBpbmdzIjoiOztBQUFBOztBQUVBO0FBQ0EseUJBQXlCOztBQUV6Qjs7QUFFQTs7Q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