﻿ //產生frame
 //因為下拉選單及使用者控制項的zindex > DIV   >  iFrame  > 下拉選單及使用者控制項
  //因為Netadvantage產生的RowEditTemplate 是屬於DIV  無法蓋住主畫面的下拉選單及使用者控制項
//所以要在此產生一個iFrame，用DIV 去蓋　iFrame (但是離開該RowEditTemplate　必須將此iFrame取消)
//此程式使用時機 參考：JobAdmin/jobrule

 function showIframe(oDiv,isShow)

                             {

                                        var IframeId = 'TemplateHelpFrame';
//產生
                                        if(isShow){
                                         var oIframe;
                                           if (!document.getElementById(IframeId))
                                               {
                                                 oIframe = document.createElement('iframe');
                                                }
                                              else
                                              {
                                              oIframe=document.getElementById(IframeId);
                                              }
                                              
                                                  oIframe.id = IframeId;

                                                  document.body.appendChild(oIframe);

              

                                                  oIframe.frameborder = 0;

                                                  oIframe.style.position = 'absolute';

                                                  oIframe.style.top = 0;

                                                  oIframe.style.left = 0;

                                                  oIframe.style.display = 'none';

												  oIframe.style.top = oDiv.style.top;
         
                                                  oIframe.style.left = oDiv.style.left;

//此iFrame的屬性都跟DIV壹樣，但是zindex 必須比DIV小

                                                  oIframe.style.zIndex = oDiv.style.zIndex - 1;

                                                  oIframe.style.width = parseInt(oDiv.offsetWidth);

                                                  oIframe.style.height = parseInt(oDiv.offsetHeight);

                                                  oIframe.style.display = 'block';

                                        }

                                        else
//取消
                                        {

                                                  var oIframe = document.getElementById(IframeId);

                                                  document.body.removeChild(oIframe);

                                        }

                              }
                              
   
//UltraWebGrid1_AfterRowTemplateOpenHandler & UltraWebGrid1_BeforeRowTemplateCloseHandler
//處理下拉選單及使用者控制項蓋住RowEditTemplate的缺點
//在屬性==>DisplayLayout==>ClientSideEvents==>AfterRowTemplateOpenHandler加入UltraWebGrid1_AfterRowTemplateOpenHandler
//及在BeforeRowTemplateCloseHandler　加入　UltraWebGrid1_BeforeRowTemplateCloseHandler
                              function UltraWebGrid1_AfterRowTemplateOpenHandler(gridName, rowId){

                              //Add code to handle your event here.

                                        var thisRow = igtbl_getRowById(rowId);
                                        var thisTemplate = igtbl_getElementById(thisRow.Band.RowTemplate);
										thisTemplate.style.overflow="auto";
									  var height =(thisTemplate.childNodes[0].height=="")?"500px":(parseInt(thisTemplate.childNodes[0].height)+2)+"px";
										if (height=='NaNpx') {height=(parseInt(thisTemplate.childNodes[0].scrollHeight)+2)+"px";}
										thisTemplate.style.height=height;
										//var tab = igtab_getTabById('UltraWebGrid1__ctl0_Positiondetail1_UltraWebTab1')
										
										//alert(tab.getSelectedTab.Key)
										
                                        showIframe(thisTemplate,true)

                                                

                            }

                    function UltraWebGrid1_BeforeRowTemplateCloseHandler(gridName, rowId, bSaveChanges){
              //var oDiv = rowTemplateId1;

                                        var thisRow = igtbl_getRowById(rowId);

                                        var thisTemplate = igtbl_getElementById(thisRow.Band.RowTemplate);

                                        showIframe(thisTemplate,false)

                      }		



                              