﻿var cancelClose=false;
function WebCombo1_BeforeSelectChange(webComboId)
{
//prevents closing of combo while selecting multiple items 
cancelClose=true; 
return true;
}

function WebCombo1_BeforeCloseUp(webComboId)
{
//Cancels premature closing.
if(cancelClose)
{
cancelClose=false; 
return true;
}
}

function WebCombo1_AfterCloseUp(webComboId)
{

//Loop through grid and find all rows that are checked and concatenate the text.
var combo=igcmbo_getComboById(webComboId);

var grid=combo.getGrid();
var rowCount=grid.Rows.length;

var displayText='';
for(i=0;i<rowCount;i++)
{
var row=grid.Rows.getRow(i);
var checked=row.getCell(1).getValue();
if(checked)
{
displayText+=row.getCell(2).getValue() + ',';
}
}

if(displayText.length>0)
{
displayText=displayText.substring(0,displayText.length-1);
}

//display the text in the combo text box 
combo.setDisplayValue(displayText);
}

 
function GridCellClickHandler(gridName, cellId, button) {
//Changes checkbox selection on any cell click in the row
var cell=igtbl_getCellById(cellId);
var boolCell=cell.Row.getCell(1);
boolCell.setValue(!boolCell.getValue());
if(boolCell.getValue())
{
cell.Element.style.backgroundColor = "Gray";
}
else
{
cell.Element.style.backgroundColor = "";
}
cancelClose=true;
}

function GridAfterCellUpdateHandler(gridName, cellId, button)
{
//Prevents dropdown from cloasing after clicking checkbox
cancelClose=true;
}

//function FillSelected()
//{ 

//var combo=document.getElementById("ctl00xContentPlaceHolder1xWebComboPaymentMathod_Main");
//alert(combo);
//var grid=combo.getGrid();
//alert("test");
//var rowCount=grid.Rows.length;

//for(i=0;i<rowCount;i++)
//{
//var row=grid.Rows.getRow(i);
//var checked=row.getCell(1).getValue();
//var textField=row.getCell(2).getValue();
//if(checked)
//{
//textField.Element.style.backgroundColor = "Gray";
//}
//else
//{
//textField.Element.style.backgroundColor = "";
//}
//}

//}


