본문 바로가기

MiPlatform

MiPlatform - Chapter6. Component별 주요기능(2-2)

>> MenuBar Component


    Dataset 이용해서 Binging
    - caption
    - id : url
    - level
   
    parent-child 관계를 지정할 수는 없어.
    level 은 connect by 등으로 구할 수 있어.
    주의. 레코드 순서가 중요해.
   
    Binging [MenuDataset : ds_menu]
    Dataset column명이 caption,id,level 이라면 다른처리 안해도 돼.
    ([CaptionCol : caption][IDCol : id][LevelCol : level])

    Event는 OnMenuClick(obj, strID)   
        // Menu Click시  처리
        function MenuBar1_OnMenuClick(obj, strID)
        {
            if( strID != "" )
                div0.Url = strID; // div의 url을 설정합니다.
        }

    MenuBar Component의 브라우저 메뉴와의 차이
    - 이쁘다 vs 안이쁘다 : GradationMode, StartColor, EndColor로 gradation 줄 수도 있다
    - Dataset바인딩 된다 vs 안된다 : 권한에 따른 메뉴변경 가능

 

>> TreeView Component


   
1) Binding
    Dataset
        level
        text
        color  [ColorColumn : color]
        그외 BkColorColumn등도 이용할 수 있지.
    Drag&Drop

2) Image 변경
    [UseImage : True]
    Image는 url연결 못시키고 resource연결만 가능. 이미지는 level순서대로 잘라짐.
   
    [ImageID : treeview_res]

    Dataset ds_bing_img 에서
        Img :보통 이미지
        eImg : 열었을때 이미지
        cImg : 닫았을때 이미지

    [InnerImageCount : 7] 이미지 하나에 몇개 있는지 지정해줘야.
    [ImageIndex : ] 기본 이미지를 몇번째것부터 사용할지
    [CollapseImageIndex : ] 닫은 이미지를 몇번째것부터 사용할지
    [ExpandImageIndex: ] 확장 이미지를 몇번째것부터 사용할지

3) Multi Select
    [MultiSelect : True]

    //Select 가져오기
        function Button3_getselect_OnClick(obj)
        {
            var        i;
            var     select_Cnt=0;
            var     msg="선택된 Record는\n";
           
            for( i = 0 ; i < ds_bind.RowCount() ; i++ )
            {
                if( ds_bind.GetSelect(i) == true )
                {
                    msg += "Row : "+i+"\n";
                    select_Cnt++;
                }
            }
            msg += "선택된 Row갯수 : " + select_Cnt;
            alert(msg);
        }
       
     //강제로 Select 설정
        function Button3_setselect_OnClick(obj)
        {
            ds_bind.SelectRow(0, true);
            ds_bind.SelectRow(1, true);
            ds_bind.SelectRow(2, true);
        }


4) Check Box
    [UseCheckBox : True]
    Dataset에 chk 컬럼만들고 Binding 시킬 수 있어.

5) 닫혀있는 상태로 시작
    [Expand : False]
   


>> Create/Object/Destroy 함수 : 동적으로 화면구성을 하고자 할 때

1) Create() : 코딩으로 component를 그릴때 사용
    function btn_create_OnClick(obj)
    {
        Create(           // Component를 동적으로 생성
                "Static", // Component이름
                "Static0", // Component ID
                "Text='sample' Left='100' Top='100' Width='100' Height='100'"); // Property설정
    }
    이벤트도 마찬가지로 처리가능

2) Object() : 만들어진 Component의 객체를 얻어올때.
    function btn_object_OnClick(obj)
    {
        alert(Object("Static0").Text); // Static0에 해당하는 Component ID찾기
    }

3) Destroy() : 만들어진 Component파괴
    function btn_destroy_OnClick(obj)
    {
        Destroy("Static0"); // Static0에 해당하는 Component제거
    }


>> File/FileDialog Component

1) FileDialog
    #include "ScriptLib::ScriptLib.js"
    function button1_OnClick(obj)
    {
        var ret;
        var path;
       
        path = GetStartXmlPath()+"File\\";
        ret = FileDialog0.Open(path);
        alert("결과 = [" + ret + "]\n" +
              "선택된 Path = [" + FileDialog0.FilePath + "]\n" +
              "선택된 File = [" + FileDialog0.FileName + "]");
    }

2) File
    function button2_OnClick(obj)
    {
        var    ret;
        var    buff;
   
        File0.FileName = FileDialog0.FilePath + "\\" + FileDialog0.FileName;
        ret = File0.Open("r"); //r:read w:wirte
        buff = File0.Read(10);    //10byte읽은거야
        alert("결과 = [" + buff + "]\n");   
        File0.Close();
    }

 

>> FTP Component

1) GetFile() : 파일 통째로 가져올때

    var file_name = "ftp_sample.txt";
    var url="demo.miplatform.com";
    var user="edu";
    var pass="edu";
   
    #include "ScriptLib::ScriptLib.js"
   
    function button1_OnClick(obj)
    {
        var local_file;
       
        // Local File경로 설정
        local_file = GetStartXmlPath() + "File\\" + file_name;
       
        // FTP Site접속
        if( ftp1.Open(url, user, pass) < 0 ) // FTP Site 접속
            alert("접속 실패");
       
        // Server로 부터 File 수신
        if( ftp1.GetFile(file_name, local_file) < 0 ) // File가져오기
            alert("File수신 실패");
       
        ftp1.Close(); // FTP Site접속 끊기
           
        alert(local_file + " File을 확인해보세요!!!");
    }


2) OpenFile() -> ReadFile() -> CloseFile() : 큰 파일을 열어놓고 부분씩 가져올떄

   
    function button2_OnClick(obj)
    {
        var local_file;
   
        // Local File경로 설정
        local_file = GetStartXmlPath() + "File\\" + file_name;
       
        // FTP Site접속
        if( ftp1.Open(url, user, pass) < 0 ) // FTP Site 접속
            alert("접속 실패");
           
        // Server File열기
        if( ftp1.OpenFile(file_name, local_file, "GET") < 0 )  // Server File 열기
            alert("File열기 실패");
       
        while(1)
        {
            var size;
            // Server File가져오기
            size = ftp1.ReadFile(10); // Server File 10 Byte씩 읽어오기
            if( size < 10 )
                break;
        }
        ftp1.CloseFile(); // Server File닫기
       
        ftp1.Close(); // FTP Site 접속 끊기
       
        alert(local_file + " File을 확인해보세요!!!");
    }

   
   

>> Script

1) F1- Script API Reference - Basic API - Method
    AddDate
    Decode
    LPad
    LTrim
    Lunar2Solar
    등등

2) Array
    function button2_OnClick(obj)
    {
        var a=array(3);
        a[0] = "1";
        a[1] = "2";
        a[2] = "3";
        for( i = 0 ; i < a.Length() ; i++ )
        {
            alert("a["+i+"]"+" = "+a[i]);
        }
    }
   
    2차원 array도 가능. 크기지정안하면 가변 array
   
3) Script Library 활용
    #include "ScriptLib::ScriptLib.js" // #include = 참조, ScriptLib::startxml에 기재된내용
    function button3_OnClick(obj)
    {
        var count;
        count = Str_Count("abcabcabc", "a");
        alert(count);
    }

4) Call By Reference : 함수호출시 argument로 값을 돌려받기.

    function func(a,b,c) // Call할 Function이며, 특별히 지정하는 것은 없습니다.
    {
        b=a;        // 변수 b가 Call By Reference를 처리할 변수이므로 이에 값을 설정합니다.
        c=Object("Button4");    // Component자체도 넘길 수 있습니다.
    }
   
    function button4_OnClick(obj)
    {
        var b, c;
        func("1234567890", Ref(b), Ref(c)); //Function을 호출할 때 Ref(변수명)으로 기술
        alert(b);
        alert(c);
    }

5) Eval : 함수를 문자형 형태로 만들어서 호출하기

    function test(a)
    {
        alert(a+"[test 호출됨]");
    }
   
    function Button5_OnClick(obj)
    {
        eval("test("+"123"+")"); // test function을 문자열 형태로 수행가능합니다.
    }

    언제쓰지? 함수명이 가변일때 편리하게 사용가능.