xdataset_multisort 가이드
데이터셋 multisort/multisortbyname API에 대한 예시 화면이다.
multisort/multisortbyname API는 정렬 순서, 정렬 데이터 형식, 정렬 범위, 완료 콜백 함수 지정 기능을 제공한다.
multisort/multisortbyname API는 사용자 정의 정렬 함수 지정 기능을 제공한다.
예시
템플릿 위치: /HTML5/COMPONENT/XDATASET/xdataset_multisort
템플릿 파일
화면 스크립트
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
/** * 데이터셋 사용자 정의 정렬 함수 * @param objInst XDataset 오브젝트 * @param nColumn 데이터셋 칼럼 인덱스 (Zero-Based) * @param nSortOrder 정렬 순서 (1(ASC)/2(DESC)) * @param nDataType 데이터 형식 (0(NUMBER)/1(STRING)) * @param strValueA 비교 대상 값 A * @param strValueB 비교 대상 값 B * @return 정렬 순서가 1(ASC)인 경우, 아래의 기준에 따름, 0: strValueA와 strValueB 값이 같은 경우, 1: strValueA와 strValueB 보다 값이 큰 경우 -1: strValueA와 strValueB 보다 값이 작은 경우 정렬 순서가 2(DESC)인 경우, 1(ASC)와 반대 값 */ function XDatasetSortFunc(objInst, nColumn, nSortOrder, nDataType, strValueA, strValueB) { var nValue1, nValueB; factory.consoleprint( "XDatasetSortFunc> " + nColumn + ", " + nSortOrder + ", " + nDataType); factory.consoleprint( "XDatasetSortFunc> strValueA = " + strValueA + ", strValueB = " + strValueB); if (nDataType == 0) { nValueA = parseFloat(strValueA); nValueB = parseFloat(strValueB); if (nSortOrder == 1) { return nValueA - nValueB; } else if (nSortOrder == 2) { return nValueB - nValueA; } else { return 0; } } else { if (strValueA == strValueB) { return 0; } if (nSortOrder == 1) { return strValueA > strValueB ? 1 : -1; } else if (nSortOrder == 2) { return strValueA > strValueB ? -1 : 1; } else { return 0; } } return 0; } /** * XDataset multisort API에서 콜백 함수 지정시 * @param objInst XDataset 오브젝트 */ function XDatasetSortCallback(objInst, nSortStartTime) { var objEndDate, nSortEndTime, nElapseSecond; objEndDate = new Date(); nSortEndTime = objEndDate.getTime(); nElapseSecond = (nSortEndTime - nSortStartTime) / 1000; factory.consoleprint( "XDatasetSortCallback> ID = " + objInst.getid() + ", SortTime = " + nElapseSecond); } function btn_multisort_on_mouseup(objInst) { var nStartRow, nEndRow; if ( this .chkRange.getcheck()) { nStartRow = this .fldStartRow.gettext(); nEndRow = this .fldEndRow.gettext(); } // this.DS_DATA.multisort("2:ASC:1:,0:DESC:1:XDatasetSortFunc", "XDatasetSortCallback"); this .DS_DATA.multisortbyname( "NUMBER:ASC:1:,ENGLISH:DESC:1:XDatasetSortFunc" , "XDatasetSortCallback" , nStartRow, nEndRow); } function btn_datatypesort_on_mouseup(objInst) { var nStartRow, nEndRow; if ( this .chkRange.getcheck()) { nStartRow = this .fldStartRow.gettext(); nEndRow = this .fldEndRow.gettext(); } if ( this .chkNumber.getcheck()) { // NUMBER 컬럼을 기준으로 숫자 형식으로 정렬 // this.DS_DATA.multisort("2:ASC:0:", "XDatasetSortCallback", nStartRow, nEndRow); this .DS_DATA.multisortbyname( "NUMBER:ASC:0:" , "XDatasetSortCallback" , nStartRow, nEndRow); } else { // NUMBER 컬럼을 기준으로 문자열 형식으로 정렬 // this.DS_DATA.multisort("2:ASC:1:", "XDatasetSortCallback", nStartRow, nEndRow); this .DS_DATA.multisortbyname( "NUMBER:ASC:1:" , "XDatasetSortCallback" , nStartRow, nEndRow); } } function grdList_on_sortcomplete(objInst, nSortStartTime) { factory.consoleprint( "grdList_on_sortcomplete> Sort Complete, nSortStartTime = " + nSortStartTime); } function screen_on_load() { } |