[ Nexacro.Grid -  Conents Editor ]

 

/*==+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * Group : 2. Conents Editor
 **=++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/


/******************************************************************************************
 * 기능 : Grid에서 컬럼명에 해당하는 값을 찾아서 Retrun
 *         콤보에 보여주는 값도 얻을 수 있음
 * 인자 : objGrid - Grid 명
 *         nRow - row
 *         asColId - 찾을 컬럼명
 * 리턴 : Grid에서 보여주고 있는 Text 값
 * 예문 :
 *****************************************************************************************/

function gfn_GetCellText(objGrid, nRow, asColId){

        return objGrid.getCellText(nRow, gfn_GetColIndex(objGrid, asColId));

}

 

/******************************************************************************************
 * 기능 : 컬럼명(영문명)에 대한 Grid index 찾아서 Return
 * 인자 : objGrid - Grid 명
 *        asColNm - physical Column name
 *        
 * 리턴 : Grid컬럼명에 대한 index
 * 예문 :
 *****************************************************************************************/

function gfn_GetColIndex(objGrid, asColNm)

{

        var nCnt = objGrid.getCellCount("Body");

        var sCurColNm;

        

        for(var i=0; i < nCnt; i++){

                sCurColNm = objGrid.getCellProperty("Body", i, 'text');

                if ('bind:' + asColNm == sCurColNm) return i;

        }

        return '';

}

 

/******************************************************************************************
 * 기능 : Grid의 binding된 컬럼명 찾기
 * 인자 : objGrid - Grid 명
 *         asTextNm - Header title name
 * 리턴 :
 * 예문 : Grid header에 대한 index
 *****************************************************************************************/

function gfn_GetGridColumnId(objGrid, anCell)

{

        var sColId = objGrid.getCellProperty("Body", anCell, "text");

        

        return sColId.replace("bind:", "");

}

 

/******************************************************************************************
 * 기능 : Grid의 특정Cell에 focus 위치시키기
 * 인자 : objGrid - Grid 명
 *         pnRow   - 포커스 갈 Row
 *         psColId - 포커스 갈 컬럼명
 * 리턴 :
 * 예문 :
 *****************************************************************************************/

function gfn_SetGridFocus(objGrd, objDs, pnRow, psColId)

{

    objDs.rowposition = pnRow;  // 오류가 있는 라인으로 이동

    objGrd.setCellPos(objGrd.getBindCellIndex("Body",psColId));

    objGrd.setFocus();

}

 

 

/*******************************************************************************
  ★ 설명
      그리드 삭제 컬럼 전체 체크
  ******************************************************************************/

 function gf_gridDelChk(obj, cellNm, cellIdx)

 {

         var bindDs = eval(obj.binddataset);

         var sTitle, sValue;

         

        sTitle = obj.getCellProperty( "head", cellIdx, "text");

         //sTitle = obj.getCellText(-1, cellIdx);

         

        bindDs.enableevent = false;

         

        if( sTitle == "삭제" )

         {

                 sTitle = "삭제-All";

                 sValue = 1;

                 obj.setCellProperty( "head", cellIdx, "text", sTitle);

                 

                for(idx=0; idx<bindDs.rowcount; idx++)

                 {

                         if( bindDs.getRowType(idx)==Dataset.ROWTYPE_INSERT

                          || bindDs.getRowType(idx)==Dataset.ROWTYPE_UPDATE )

                         {

                                 continue;

                         }

                         bindDs.setColumn(idx,cellNm,sValue);

                 }

         }

         else

         {

                 sTitle = "삭제"

                 sValue = "0";

                 obj.setCellProperty( "head", cellIdx, "text", sTitle);

                 

                for(idx=0; idx<bindDs.rowcount; idx++)

                 {

                         if( bindDs.getRowType(idx)==Dataset.ROWTYPE_INSERT

                          || bindDs.getRowType(idx)==Dataset.ROWTYPE_UPDATE )

                         {

                                 ////trace("continue["+idx+"]::"+ bindDs.getRowType(idx));

                                 if(bindDs.getColumn(idx,cellIdx-1)=="수정" || bindDs.getColumn(idx,cellIdx-1)=="입력" )

                                 {

                                         continue;

                                 }

                         }

                         bindDs.setColumn(idx,cellNm,sValue);

                 }

         }

         

        bindDs.enableevent = true;                

}

 

/*******************************************************************************
  ★ 설명
      Grid Column Head Fix 하는 함수(Header Fix 컬러 변경)
  ★ parameter
    1. obj:Grid : Grid Object ( 예 : Grid00 )
     2. nCellIdx : Click Event Object ( Grid Col Index )
     
 ★ return
    - 성공 = true
     - 실패 = false
  ******************************************************************************/

function gf_gridColFix(obj:Grid, nCellIdx, sFixColor)

 {

 //trace( "gf_gridColFix["+nCellIdx+"/"+obj.getCellCount("Head")+"] ");

         var nCell;

         var sDefaultFixColor = "lightgrey";

         var sDefaultBgImage = "URL('img::img_GridPil.png')";

         

        for(nCell = 0; nCell <= nCellIdx; nCell++)

        {

                 //obj.setFormatColProperty(nCell,"fix","");

                 obj.setFormatColProperty(nCell,"band","");

                 

                if( obj.getFormatColProperty(nCell,"band") == "right" ) break;

                 

                var bgProp = ""+obj.getCellProperty("head",nCell,"background");

                 ////trace( "bgProp : " + obj.getCellProperty("head",nCell,"background") );

                 if( nCell <= nCellIdx )

                 {

                         ////trace( "nCell : " + nCell );

                         obj.setFormatColProperty(nCell,"band","left");

                         if(bgProp==null || bgProp=="")

                         {

                                 obj.setCellProperty("head",nCell,"background",sDefaultFixColor);

                         }

                         else if(sDefaultBgImage.indexOf(bgProp)!=-1 || sDefaultFixColor.indexOf(bgProp)!=-1)

                         {

                                 obj.setCellProperty("head",nCell,"background",sDefaultFixColor + " " + bgProp);

                         }

                         else

                         {

                                 ////trace("nCel/IdxnCell ["+nCellIdx+"/" + nCell +"]="+bgProp);

                                 obj.setCellProperty("head",nCell,"background",sDefaultFixColor);

                         }

                 }

                else

                 {

                         obj.setFormatColProperty(nCell,"band","body");

                         

                        if(bgProp==null || bgProp=="")

                         {

                                 obj.setCellProperty("head",nCell,"background","");

                        }

                         else if(bgProp.indexOf(sDefaultBgImage)!=-1)

                         {

                                 obj.setCellProperty("head",nCell,"background",obj.getCellProperty("head",nCell,"background"));

                        }

                         else

                         {

                                 obj.setCellProperty("head",nCell,"background","");

                         }                       

                }

                //trace("background["+nCell+"] ===========>"+obj.getCellProperty("head",nCell,"background"));

         }

 }

 

/*******************************************************************************
  ★ 설명
      Grid Column Head Fix 해제 하는 함수(Header Fix 컬러 변경)
  ★ parameter
    1. obj:Grid : Grid Object ( 예 : Grid00 )
    2. nCellIdx : Click Event Object ( Grid Col Index )
    3. nStartIdx : 기본 Fix Column Index
  ******************************************************************************/

function gf_gridColFixFree(obj:Grid, nCellIdx, nStartIdx)

 {

 //trace( "gf_gridColFixFree["+nCellIdx+"/"+nStartIdx+"] ");

         var nCell;

         var sDefaultFixColor = "lightgrey";

         var sDefaultBgImage = "URL('img::img_GridPil.png')";

         

        var nStart = obj.getCellCount("Head") - 1;

         

        //for(nCell = obj.getCellCount("Head"); nCell > 0 ; nCell--)

        for(nCell = nStart; nCell > nStartIdx ; nCell--)

        {

                 if( obj.getFormatColProperty(nCell,"band") == "right" || obj.getFormatColProperty(nCell,"band") == "body" )

                        continue;

 

                //gridObj.setFormatColProperty(nCell-1,"fix","");

                 obj.setFormatColProperty(nCell,"band","body");

 

                var bgProp = ""+obj.getCellProperty("head",nCell,"background");

                 

                //trace( "["+nCell+"/"+bgProp.indexOf(sDefaultBgImage)+"] "+sDefaultBgImage+"   // bgProp = " + obj.getCellProperty("head",nCell,"background") );

                 if(bgProp==null || bgProp=="")

                 {

                         obj.setCellProperty("head",nCell,"background","");

                 }

                 else if(bgProp.indexOf("URL")!=-1)

                 {

                        obj.setCellProperty("head",nCell,"background",sDefaultBgImage);

                 }

                 else

                 {

                         obj.setCellProperty("head",nCell,"background","");

                 }       

                //trace("background["+nCell+"/"+nStartIdx+"] =========== "+obj.getCellProperty("head",nCell,"background"));

         }

        

}

☞  

 

☞  

 
 
 
 

  

 

'Nexacro-Function > Grid' 카테고리의 다른 글

Nexacro.Grid - treeView  (0) 2017.01.28
Nexacro.Grid - excel exort  (0) 2017.01.28
Nexacro.Grid - copy & paste  (0) 2017.01.28
Nexacro.Grid - all Checked 처리  (0) 2017.01.28
Nexacro.Grid - grid header  (0) 2017.01.28
Posted by 농부지기
,