📄 ig_webcombo3_1.js
字号:
}
else {
if(this.Dropped == false)
return;
var grid = igcmbo_getElementById(this.ClientUniqueId + "_container");
if(igcmbo_fireEvent(this.ClientUniqueId,this.Events.BeforeCloseUp,"(\""+this.ClientUniqueId+"\");")) {
return;
}
if(this.webGrid)
this.webGrid.Element.setAttribute("noOnResize",true);
grid.style.visibility = 'hidden';
grid.style.display = "none";
this.Dropped = false;
if(this.HideDropDowns) igcmbo_hideDropDowns(false);
var inputbox = igcmbo_getElementById(this.ClientUniqueId + "_input");
igcmbo_currentDropped = null;
igcmbo_fireEvent(this.ClientUniqueId,this.Events.AfterCloseUp,"(\""+this.ClientUniqueId+"\");");
if(this.webGrid){
igcmbo_wgNoResize=this.webGrid;
setTimeout(igcmbo_clearnoOnResize, 100);
}
}
}
function igcmbo_clearInternalDrop() {
if(igcmbo_currentDropped) igcmbo_currentDropped._internalDrop = null;
}
var igcmbo_wgNoResize=null;
function igcmbo_clearnoOnResize() {
if(igcmbo_wgNoResize){
igcmbo_wgNoResize.Element.removeAttribute("noOnResize");
igcmbo_wgNoResize=null;
}
}
function igcmbo_editkeydown(evnt,comboId) {
var oCombo = igcmbo_getComboById(comboId);
if(oCombo && oCombo.Loaded) {
var keyCode = (evnt.keyCode);
var newValue = igcmbo_srcElement(evnt).value;
if(igcmbo_fireEvent(oCombo.ClientUniqueId,oCombo.Events.EditKeyDown,"('"+oCombo.ClientUniqueId+"','"+newValue+"',"+keyCode+");"))
return igtbl_cancelEvent(evnt);
if(oCombo.eventHandlers["keydown"] && oCombo.eventHandlers["keydown"].length>0){
var ig_event=new ig_EventObject();
ig_event.event=evnt;
for(var i=0;i<oCombo.eventHandlers["keydown"].length;i++)
if(oCombo.eventHandlers["keydown"][i].fListener)
{
if(keyCode==9 || keyCode==13 || keyCode==27)
oCombo.setDisplayValue(newValue,false);
oCombo.eventHandlers["keydown"][i].fListener(oCombo,ig_event,oCombo.eventHandlers["keydown"][i].oThis);
if(ig_event.cancel)
return igtbl_cancelEvent(evnt);
}
}
if (oCombo.ComboTypeAhead!=0 && igcmbo_isCountableKey(keyCode) )
oCombo.keyCount++;
if (!oCombo.Editable&&oCombo.ComboTypeAhead==1)
{
if(oCombo.DataTextField.length>0)column=oCombo.getGrid().Bands[0].getColumnFromKey(oCombo.DataTextField)
else column=oCombo.getGrid().Bands[0].Columns[0];
var s=String.fromCharCode(evnt.keyCode);
if (igcmbo_isCountableKey(evnt.keyCode)){
var cell=null;
var row;
cell = igcmbo_typeaheadFindCell(oCombo,s, column, oCombo.lastKey);
if(cell){
oCombo.lastKey = s;
text = igcmbo_processTypeAhead(oCombo,oCombo.getGrid(),cell);
newValue=text;
}
}
else{
var oText=igcmbo_ProcessNavigationKey(oCombo,column,evnt.keyCode,evnt);
if (oText) newValue=oText;
}
}
oCombo.updatePostField(newValue);
oCombo.displayValue = newValue;
if(keyCode==38 || keyCode==40)
return igtbl_cancelEvent(evnt);
}
}
// private function
// used to determine what keys will trigger type ahead counter increment/decrements
function igcmbo_isCountableKey(keyCode){
if (keyCode<32)
return false;
switch(keyCode){
//end//right//home//left
case 35: case 39: case 36: case 37:
//back//del
case 8: case 46:
//up//down
case 38: case 40:
return false;
break;
}
return true;
}
// private function
function igcmbo_arrowKeyNavigation(oCombo, oGrid, oRow, column){
var text = null;
if(oRow != null){
oGrid.setActiveRow(oRow);
oGrid.clearSelectionAll();
oRow.setSelected(true);
oCombo.selectedIndex = oRow.getIndex();
var cell = oRow.getCell(column.Index);
text = cell.getValue(true);
oCombo.updateValue(text, true);
if(oCombo.DataValueField) oCombo.dataValue=oRow.getCellFromKey(oCombo.DataValueField).getValue();
igtbl_updatePostField(oGrid.Id);
}
return text;
}
// private function
function igcmbo_highlightText(){
var oInput = document.getElementById(this.ClientUniqueId + "_input");
if (null==oInput)return;
var oInTextRange= oInput.createTextRange?oInput.createTextRange():null;
if (this.Editable){
if (oInTextRange){
oInTextRange.moveStart("character",this.ComboTypeAhead==2&&this.lastKey?this.lastKey.length:0);
oInTextRange.moveEnd("textedit");
oInTextRange.select();
}
else if (oInput.selectionStart){
oInput.selectionStart = this.lastKey?this.lastKey.length:0;
oInput.selectionEnd = oInput.value.length;
}
}
else{
oInput.style.backgroundColor = this.SelBackColor;
oInput.style.color = this.SelForeColor;
}
}
// private function
function igcmbo_typeAheadReset(comboId){
var oCombo = igcmbo_getComboById(comboId);
if (oCombo){
oCombo.keyCount=0;
oCombo.typeAheadTimeout=null;
if (2==oCombo.ComboTypeAhead)
oCombo.lastKey="";
}
}
// private
function igcmbo_typeaheadFindCell(oCombo,charFromCode, column, lastKey){
var cell=null;
var re=new RegExp("^"+igtbl_getRegExpSafe(charFromCode),"gi");
if(lastKey!=charFromCode) cell=column.find(re);
else if(cell==null){
cell=column.findNext();
if(cell==null) cell=column.find(re);
}
return cell;
}
//private
function igcmbo_processTypeAhead(oCombo,oGrid,oCell){
var text=null;
text=oCell.getValue(true);
var oRow=oGrid.getActiveRow();
oGrid.clearSelectionAll();
if(oRow) oRow.setSelected(false);
oRow=oCell.getRow();
oGrid.setActiveRow(oRow);
oRow.setSelected(true);
oCombo.selectedIndex=oRow.getIndex();
oCombo.updateValue(text, true);
if(oCombo.DataValueField) oCombo.dataValue=oRow.getCellFromKey(oCombo.DataValueField).getValue();
igtbl_updatePostField(oGrid.Id);
oCombo.highlightText();
return text;
}
//private
function igcmbo_ProcessNavigationKey(oCombo,column,keyCode,evnt){
var oRow=null;
var oGrid=oCombo.getGrid();
var oText=null;
switch(keyCode){
case 8: case 46:
if (oCombo.Editable){
document.selection.createRange().text="";
oCombo.lastKey=igcmbo_srcElement(evnt).value;
}
break;
case 40:
oRow=oGrid.getActiveRow();
if(oRow!=null){
oRow.setSelected(false);
var oRow=oRow.getNextRow();
oText=igcmbo_arrowKeyNavigation(oCombo,oGrid,oRow,column);
}
else if (oGrid.Rows.length>0) oText=igcmbo_arrowKeyNavigation(oCombo,oGrid,oGrid.Rows.getRow(0),column);
break;
case 38:
oRow = oGrid.getActiveRow();
if(oRow != null){
oRow.setSelected(false);
var oRow = oRow.getPrevRow();
oText = igcmbo_arrowKeyNavigation(oCombo,oGrid,oRow,column);
}
else if (oGrid.Rows.length > 0) oText=igcmbo_arrowKeyNavigation(oCombo,oGrid,oGrid.Rows.getRow(oGrid.Rows.length-1),column);
break;
}
return oText;
}
function igcmbo_editkeyup(evnt,comboId) {
var oCombo = igcmbo_getComboById(comboId);
if(oCombo&&oCombo.Loaded){
var keyCode=(evnt.keyCode);
var charFromCode=String.fromCharCode(evnt.keyCode);
var newValue = oCombo.Editable ? igcmbo_srcElement(evnt).value:charFromCode;
if(igcmbo_fireEvent(oCombo.ClientUniqueId,oCombo.Events.EditKeyUp,"(\""+oCombo.ClientUniqueId+"\",\""+newValue+"\","+keyCode+");"))
return igtbl_cancelEvent(evnt);
if (0==oCombo.ComboTypeAhead) return;
var bCountableKey=igcmbo_isCountableKey(keyCode);
if (bCountableKey) --oCombo.keyCount;
var lastKey=oCombo.lastKey;
if (2==oCombo.ComboTypeAhead)
if (oCombo.Editable)charFromCode=newValue;
else{
charFromCode=(bCountableKey?(lastKey?lastKey:"")+newValue:null);
oCombo.lastKey=charFromCode;
}
else
oCombo.lastKey = charFromCode;
if (oCombo.keyCount==0){
var oGrid=oCombo.getGrid();
if(oGrid==null) return;
var column=null;
if(oCombo.DataTextField.length>0)column=oGrid.Bands[0].getColumnFromKey(oCombo.DataTextField)
else {
var colNo=0;
column=oGrid.Bands[0].Columns[colNo];
}
if(column==null) return;
var text;
var cell;
var oCurrentRow=null;
if(charFromCode&&bCountableKey){
cell=igcmbo_typeaheadFindCell(oCombo,charFromCode,column,lastKey);
if(cell!=null){
oCombo.lastKey=charFromCode;
text=igcmbo_processTypeAhead(oCombo,oGrid,cell);
oCombo.typeAheadTimeout = null;
oCombo.typeAheadTimeout = setTimeout("igcmbo_typeAheadReset('"+oCombo.ClientUniqueId+"')",1000);
if (!oCombo.Editable) newValue=text;
}
else {
var oEditor=document.getElementById(oCombo.ClientUniqueId + "_input");
if (!oCombo.Editable){
var oActRow=oGrid.getActiveRow();
if (oActRow) oEditor.value= oCombo.DataTextField!=null && oCombo.DataTextField!="" ? oActRow.getCellFromKey(oCombo.DataTextField).getValue() : oActRow.getCell(0).getValue();
newValue=oEditor.value;
oCombo.highlightText();
}
else // if editable and no row is found we should move off all rows since this may be a new value
{
oGrid.clearSelectionAll();
oGrid.setActiveRow(null);
oCombo.selectedIndex = -1;
//oCombo.updateValue(charFromCode, true);
//igtbl_updatePostField(oGrid.Id);
newValue=charFromCode;
}
oCombo.typeAheadTimeout=setTimeout("igcmbo_typeAheadReset('"+oCombo.ClientUniqueId+"')",1000);
}
}
else{
var oText=igcmbo_ProcessNavigationKey(oCombo,column,evnt.keyCode,evnt);
if (null!=oText) newValue=oText;
}
}
else
oCombo.typeAheadTimeout=setTimeout("igcmbo_typeAheadReset('"+oCombo.ClientUniqueId+"')",500);
oCombo.updatePostField(newValue);
oCombo.displayValue=newValue;
}
}
function igcmbo_onfocus(evnt,comboId) {
var oCombo = igcmbo_getComboById(comboId);
if(!oCombo)
return;
oCombo.setFocusTop();
oCombo.highlightText();
}
function igcmbo_onblur(evnt,comboId) {
var oCombo = igcmbo_getComboById(comboId);
if(!oCombo || !oCombo.Loaded)
return;
// moved this outside the loop
var inputbox = igcmbo_getElementById(oCombo.ClientUniqueId + "_input");
if (inputbox)
{
if (!oCombo.Editable){
inputbox.style.backgroundColor = oCombo.BackColor;
inputbox.style.color = oCombo.ForeColor;
}
else{
var oGrid = oCombo.getGrid();
var oEditor=document.getElementById(oCombo.ClientUniqueId + "_input");
var oActRow=oGrid.getActiveRow();
if (oActRow)
{
var oCellValue = oCombo.DataTextField!=null && oCombo.DataTextField!="" ? oActRow.getCellFromKey(oCombo.DataTextField).getValue():oActRow.getCell(0).getValue();
if (oEditor.value!=oCellValue)
{
oGrid.clearSelectionAll();
oGrid.setActiveRow(null);
oCombo.selectedIndex = -1;
oCombo.updateValue(oEditor.value, true);
igtbl_updatePostField(oGrid.Id);
}
}
oCombo.updatePostField(oEditor.value);
}
}
if(oCombo!=igcmbo_displaying)
return;
if (document.all && oCombo.Element.contains(evnt.toElement)) {
}
else {
if(oCombo.webGrid != null) {
var container = igcmbo_getElementById(oCombo.ClientUniqueId + "_container");
if(oCombo._internalDrop || oCombo.Element.getAttribute("noOnBlur"))
return;
if(oCombo.eventHandlers["blur"] && oCombo.eventHandlers["blur"].length>0)
{
var ig_event=new ig_EventObject();
ig_event.event=evnt;
for(var i=0;i<oCombo.eventHandlers["blur"].length;i++)
if(oCombo.eventHandlers["blur"][i].fListener)
{
oCombo.eventHandlers["blur"][i].fListener(oCombo,ig_event,oCombo.eventHandlers["blur"][i].oThis);
if(ig_event.cancel)
return igtbl_cancelEvent(evnt);
}
}
}
}
}
function igcmbo_setFocusTop() {
var inputbox = igcmbo_getElementById(this.ClientUniqueId + "_input");
if(this.Editable)
inputbox.select();
else{
inputbox.style.backgroundColor=this.SelBackColor;
inputbox.style.color=this.SelForeColor;
}
try{
if(document.all)inputbox.focus();
}
catch(e){}
}
// private - event initialization for combo object
function igcmbo_events(events){
this.InitializeCombo=events[0];
this.EditKeyDown=events[1];
this.EditKeyUp=events[2];
this.BeforeDropDown=events[3];
this.AfterDropDown=events[4];
this.BeforeCloseUp=events[5];
this.AfterCloseUp=events[6];
this.BeforeSelectChange=events[7];
this.AfterSelectChange=events[8];
}
function igcmbo_gridmouseover(gridName, itemId) {
var grid = igtbl_getGridById(gridName);
var cell = igtbl_getCellById(itemId);
if(cell == null)
return;
igtbl_clearSelectionAll(gridName);
igtbl_selectRow(gridName,cell.Row.Element.id);
}
function igcmbo_gridkeydown(gridName, itemId, keyCode) {
igtbl_clearSelectionAll(gridName);
var oCombo = igcmbo_currentDropped;
if(keyCode == 27 || keyCode == 10) {
oCombo.setDropDown(false);
oCombo.setFocusTop();
}
}
function igcmbo_gridrowactivate(gridName, itemId) {
var oCombo = igcmbo_getComboByGridName(gridName);
//var oCombo = igcmbo_currentDropped;
var row = igtbl_getRowById(itemId);
if(oCombo == null || row == null)
return;
if(oCombo.DataTextField.length > 0) {
cell = row.getCellFromKey(oCombo.DataTextField);
}
else
cell = row.getCell(0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -