[ Nexacro.Grid -  grid header ]

 

/*==+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * Group : 1. Grid Header 관련 함수
 * Group : 2. Conents Editor
 * Group : 3. Copy & Paste
 **=++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

 

/*==+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * Group : 1. Grid Header 관련 함수
 **=++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

 


/******************************************************************************************
 * 기능 : Grid의 Head.이름에 해당하는 index 를 반환
 * 인자 : objGrid - Grid 명
 *         asTextNm - Header title name
 * 리턴 : Grid header에 대한 index
 * 예문 :
 *****************************************************************************************/

function gfn_GetHeadIndex(objGrid, asTextNm)

{

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

        var sCurTextNm;

        

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

                sCurTextNm = objGrid.getCellProperty("Head", i, 'text');

                if (asTextNm == sCurTextNm) return i;

        }

        return '';

}

 

/******************************************************************************************
 * 기능 : Grid의 Head.이름에 해당하는 index 를 반환 (중간에만 있어도 해당 index 반환)
 * 인자 : objGrid - Grid 명
 *         asTextNm - Header title name
 * 리턴 : Grid header에 대한 index
 * 예문 :
 *****************************************************************************************/

function gfn_GetHeadIndexLike(objGrid, asTextNm)

{

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

        var nLastIdx;

 

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

                sCurTextNm = objGrid.getCellProperty("Head", i, 'text');

                

                if ( sCurTextNm.indexOf(asTextNm) >=0  ) return i;

        }

        return '';

}


/*******************************************************************************
 ★ 설명
     Grid Sorting하는 함수(Header Sorting여부 표시 포함)
 ★ parameter
    1. obj:Grid : Grid Object ( 예 : Grid00 )
    2. e:GridClickEventInfo : Click Event Object ( Grid Onclick Envent의 Argument e )
    3. ASC_MARK : Ascending Mark (옵션 : Default = "▼")( 예 : "▼" )
    4. DESC_MARK : Descending Mark (옵션 : Default = "▲")( 예 : "▲" )
    5. sSortMark    : Sorting 강제 지정 (옵션 : Default = "" ==> 상태에 따라 알아서 함)
                      (예 : ASC_MARK 또는 DESC_MARK 지정 )
 ★ return
    - 성공 = true
    - 실패 = false
 ******************************************************************************/

function GridSort(obj:Grid, e:GridClickEventInfo, ASC_MARK, DESC_MARK, sSortMark)

{

 if( fn_IsNull(obj) || fn_IsNull(e) ) return false;

 

 // 컬럼의 정렬방식을 'head'의 text에 "↑,↓"여부로 판단.

 // 이미지로 대체 가능.

 var bindDs = eval(obj.binddataset);

 var i, cell_cnt;

 

 if (bindDs.rowcount == 0) return false;

 if( fn_IsNull(ASC_MARK) )  ASC_MARK = "▼";

 if( fn_IsNull(DESC_MARK) )  DESC_MARK = "▲";

 

 cell_cnt = obj.getCellCount("head");

 var BodyColId = (obj.getCellProperty("body", e.col,"text")).toString().split(":"); // e.col : 바인드된 컬럼.

                     

 for( i = 0 ; i < cell_cnt ; i++ )

 {

  if(obj.getCellText(-1, i)=="undefined")

   continue;

  

  var strHeadText = obj.getCellText(-1, i);

 

  if(i==e.cell)

  {

   if(strHeadText.substr(strHeadText.length-1) == ASC_MARK)

   {

    if( fn_IsNull(sSortMark) || sSortMark == DESC_MARK )

    {

     obj.setCellProperty( "head", i, "text", strHeadText.substr(0, strHeadText.length - 1)+DESC_MARK);

     bindDs.keystring = "S:-"+BodyColId[1];

    }

   }

   else if (strHeadText.substr(strHeadText.length-1) == DESC_MARK)

   {

    if( fn_IsNull(sSortMark) || sSortMark == ASC_MARK )

    {

     obj.setCellProperty( "head", i, "text", strHeadText.substr(0, strHeadText.length - 1)+ASC_MARK);

     bindDs.keystring = "S:+"+BodyColId[1];

    }

   }

   else

   {

    var def_mark;

    if( fn_IsNull(sSortMark) ) def_mark = ASC_MARK;

    else     def_mark = sSortMark;

     

    obj.setCellProperty( "head", i, "text", strHeadText+def_mark);

    if( def_mark == ASC_MARK )

     bindDs.keystring = "S:+"+BodyColId[1];

    else

     bindDs.keystring = "S:-"+BodyColId[1];

   }

  }

  else // 정렬표시 삭제

  {

   if (strHeadText.substr(strHeadText.length-1) == ASC_MARK || strHeadText.substr(strHeadText.length-1) == DESC_MARK)

   {

    obj.setCellProperty( "head", i, "text", strHeadText.substr(0, strHeadText.length - 1));

   }

  }

 }

 return true;

}

/******************************************************************************
  * Function명 : gf_gridCheckAll
  * 설명       : 그리드에서 특정 컬럼의 체크박스를 모두 체크하거나 체크 해제
  * Params     : gridObj       - Grid
  *              cellNm        - 해당 cell의 Bind된 Dataset 컬럼명
  *              cellIdx       - cell index
  * Return     :
  ******************************************************************************/

 function gf_gridCheckAll(gridObj:Grid, cellNm, cellIdx)

 {

         var edittype = gridObj.getCellProperty( "head", cellIdx, "edittype");

         

        if (edittype != "checkbox") return;

         

        var bindDs = eval(gridObj.binddataset);

         var checkValue = gridObj.getCellProperty( "head", cellIdx, "text");

         

        if (gf_isNull(checkValue)) checkValue = 0;

         

        checkValue = (checkValue == 0)  1 : 0;

 

        gridObj.setCellProperty( "head", cellIdx, "text", checkValue);

         

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

         {

                 if( bindDs.getRowType(idx) == Dataset.ROWTYPE_DELETE ) continue;

                 bindDs.setColumn(idx, cellNm, ((checkValue == 0)  0 : 1));

        }

 }

 

☞  

 
 
 
 

  

 

'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 - Conents Editor  (0) 2017.01.28
Nexacro.Grid - all Checked 처리  (0) 2017.01.28
Posted by 농부지기
,