데이터 관련
Methods
(static) addAsyncCommand()
콜백 안에서도 사용자 메소드를 실행 가능하도록 비동기 큐에 명령을 저장한다
beforeEdit,afterEdit,beforeSave,afterSave안에서만 호출 가능
Example
셀의 값을 변경하고 엔터를 눌렀을때, 자체적으로 데이터를 검증 후 셀의 값을 변경하거나 선택된 셀의 위치를 변경 할 수 있다.
afterSave: function (colid,beforeValue,value,rownum) {
var colnum = this.getColumn().indexOf(colid);
if( value != "celltext"){ // 입력된 데이터 값 검증해서 잘못 입력했다면
this.addAsyncCommand(function(){ //
this.setCell([{rowid:rownum,columnid:colid,data:'initValue'}]) //원하는 값으로 셀의 값 변경
this.setSelection(true,rownum,colnum) //원하는 위치로 셀 선택 위치 변경
});
}
},
(static) addAverageColumn(columnData, columnid) → {undefined}
평균 컬럼을 추가합니다
Example
grid.addAverageColumn({id:'avgdata', name:'평균'}, ['pr_sale', 'pr_buy']);
Parameters:
Name | Type | Description |
---|---|---|
columnData |
object | 평균컬럼의 기초데이터 {id:'avgdata', name:'평균'} |
columnid |
string | 평균을 구할 컬럼아이디의 배열 |
Returns:
- Type
- undefined
(static) addColumn(colunmData, targetColumnIdopt) → {undefined}
컬럼을 추가합니다
Example
grid.addColumn({id:'USER_SABUN', name:'사번'}, "USER_DEP"); //USER_DEP 컬럼 앞에 사번 컬럼 생성
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
colunmData |
object | 컬럼 생성 기초 데이터 {id:'USER_SABUN', name:'사번'} | |
targetColumnId |
string |
<optional> |
입력한 컬럼의 앞에 추가됨, 입력하지않으면 제일마지막에 추가됨 |
Returns:
- Type
- undefined
(static) addRow(rowIndex|rowdataopt, rowdataopt) → {boolean}
로우를 추가합니다
메소드 호출시마다 렌더링이 되기 때문에, 반복적인 호출에는 적합하지 않습니다
Example
grid.addRow();//마지막로우에 빈데이터 추가
grid.addRow(0);//첫번째 줄에 빈로우 추가
grid.addRow({'USER_SABUN':1});//마지막로우에 데이터를 추가
grid.addRow(1,{'USER_SABUN':1});//두번째로우에 데이터를 추가
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
rowIndex|rowdata |
number | object |
<optional> |
파라메터를 한개만 사용할때는 로우번호,데이터 둘다 올수있음, 파라메터를 두개 사용할 경우 rowIndex로 사용해야함 |
rowdata |
object |
<optional> |
로우 데이터 |
Returns:
추가 시 true
- Type
- boolean
(static) addSumColumn(columnData, columnid) → {undefined}
합계 컬럼을 추가합니다
Example
grid.addSumColumn({id:'sumdata', name:'합계'}, ['pr_sale', 'pr_buy']);
Parameters:
Name | Type | Description |
---|---|---|
columnData |
object | 합계컬럼의 기초데이터 {id:'sumdata', name:'합계'} |
columnid |
string | 합계를 구할 컬럼아이디의 배열 |
Returns:
- Type
- undefined
(static) afterColMerge(coordinateArray) → {undefined}
row merge이후에 col merge 기능을 활성화 합니다
Example
grid.afterColMerge([1,2,3]);
Parameters:
Name | Type | Description |
---|---|---|
coordinateArray |
array | merge할 컬럼의 번호 배열 |
Returns:
- Type
- undefined
(static) cancelEdit() → {undefined}
현재 수정중인 데이터의 편집을 취소합니다
Example
grid.cancelEdit();
Returns:
- Type
- undefined
(static) clearChecked(로우)
모든 체크박스 선택을 비활성화 합니다
Example
grid.clearChecked(); //모든로우의 체크박스 선택을 비활성화
grid.clearChecked([0,1]); // 0,1번 로우의 체크박스 선택을 비활성화
Parameters:
Name | Type | Description |
---|---|---|
로우 |
array | 번호 |
(static) clearEditedData(typeopt) → {undefined}
변경된 데이터 내역을 초기화합니다
Example
grid.clearEditedData();//변경내역 데이터 모두 초기화
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
array |
<optional> |
['add','delete','update']
|
null일경우 모두 초기화 |
Returns:
- Type
- undefined
(static) copyRow(copyRowIndex, targetRowIndex) → {undefined}
로우를 복사합니다
Example
grid.copyRow(0,1); //첫번째 로우를 두번째 로우위치에 복사
Parameters:
Name | Type | Description |
---|---|---|
copyRowIndex |
number | 복사될 로우 번호 |
targetRowIndex |
number | 복사될 곳의 로우 번호 |
Returns:
- Type
- undefined
(static) deleteAllData() → {undefined}
모든 데이터를 삭제합니다
Example
grid.deleteAllData();
Returns:
- Type
- undefined
(static) deleteColumn(columnid) → {undefined}
컬럼을 삭제합니다
Example
grid.deleteColumn('USER_SABUN');
Parameters:
Name | Type | Description |
---|---|---|
columnid |
string | 삭제할 컬럼 아이디 |
Returns:
- Type
- undefined
(static) deleteRow(idxOrArray) → {boolean}
지정한 로우를 삭제합니다
Example
grid.deleteRow(0); //첫번째 로우 삭제
grid.deleteRow([0,1,2]); //첫번째에서 세번째 로우까지 삭제
Parameters:
Name | Type | Description |
---|---|---|
idxOrArray |
number | array | 삭제할 로우의 한개 혹은 배열 |
Returns:
성공여부
- Type
- boolean
(static) getAllData() → {array}
모든 데이터를 반환합니다
Example
grid.getAllData();
Returns:
모든 데이터
- Type
- array
(static) getAllDataID() → {array}
모든 데이터에 대한 idx를 반환합니다
Example
grid.getAllDataID();
Returns:
idx배열
- Type
- array
(static) getCellData(rowid, columnid) → {string}
선택된 셀의 데이터를 반환합니다
Example
grid.getCellData(0,"USER_SABUN");//첫번째 줄의 'USER_SABUN' 컬럼 데이터 반환
Parameters:
Name | Type | Description |
---|---|---|
rowid |
number | 로우 번호 |
columnid |
string | 컬럼의 아이디 |
Returns:
셀 데이터
- Type
- string
(static) getCheckedRowID(excludeHiddenRow) → {array}
체크된 데이터의 로우번호 배열을 반환합니다
Example
grid.getCheckedRowID();
Parameters:
Name | Type | Description |
---|---|---|
excludeHiddenRow |
boolean | true로 설정시 화면에 보이는 로우 번호만 반환 |
Returns:
체크된 데이터의 로우번호 배열
- Type
- array
(static) getColumn(includeHiddenColumnopt) → {array}
그리드의 컬럼정보를 반환합니다.
Example
grid.getColumn(); //숨김컬럼 포함 반환
grid.getColumn(false); //숨김컬럼 제외 반환
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
includeHiddenColumn |
boolean |
<optional> |
true
|
숨김컬럼 포함여부 |
Returns:
그리드의 컬럼 정보 반환
- Type
- array
(static) getEditCellPosition() → {object|null}
현재 수정중인 데이터의 셀 좌표를 반환합니다
Example
grid.getEditCellPosition();
Returns:
수정중인 셀의 좌표,편집을 사용하지 않을때는 null을 반환
- Type
- object | null
(static) getEditedData(typeopt, hasBeforeData) → {object}
변경된 데이터 내역을 반환합니다
Example
grid.getEditedData();//변경내역 데이터 모두
grid.getEditedData(['add']);//추가된 데이터 내역만 반환
grid.getEditedData(null,true);//모든변경내역과 변경이전데이터 포함 반환
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
array |
<optional> |
['add','delete','update']
|
null일경우 모두 반환 |
hasBeforeData |
boolean |
false
|
변경이전 데이터 포함 여부 |
Returns:
add,delete,update로 분리된 변경내역 데이터
- Type
- object
(static) getRowData(rowid) → {object}
선택된 로우의 데이터를 반환합니다
Example
grid.getRowData(0);//첫번째 줄 데이터 반환
Parameters:
Name | Type | Description |
---|---|---|
rowid |
number | 로우 번호 |
Returns:
로우 데이터
- Type
- object
(static) getViewportRowCount() → {number}
현재 사용자에게 보여지는 로우 갯수를 가져옵니다.
Example
grid.getViewportRowCount();
Returns:
로우 수
- Type
- number
(static) getViewportRowRange() → {object}
현재 사용자에게 보여지는 로우 범위를 가져옵니다.
Example
grid.getViewportRowRange();
Returns:
로우범위 시작과 끝 번호{start:0,end:15}
- Type
- object
(static) getVisibleRowCount() → {number}
데이터 총 갯수에서 로우숨김, 필터 설정으로 보이지않는 로우 수를 뺀 수를 반환합니다
Example
grid.getVisibleRowCount();
Returns:
로우 수
- Type
- number
(static) hideColumn(colunmId) → {undefined}
컬럼을 숨깁니다
멀티헤더에서는 최하위 컬럼명에 대해서만 동작합니다
Example
grid.hideColumn('USER_SABUN');
Parameters:
Name | Type | Description |
---|---|---|
colunmId |
string | 숨길 컬럼 아이디 |
Returns:
- Type
- undefined
(static) hideRow(rowIndex) → {undefined}
로우를 숨깁니다
Example
grid.hideRow(0); //첫번째 로우 숨김
Parameters:
Name | Type | Description |
---|---|---|
rowIndex |
number | 로우 번호 |
Returns:
- Type
- undefined
(static) moveAllRowToGrid(toGrid, toRowIndex) → {undefined}
전체 로우데이터를 다른 그리드로 내보냅니다
Example
var leftGrid = hg.hgrid({...}); //왼쪽그리드 생성
var rightGrid = hg.hgrid({...}); //오른쪽그리드 생성
leftGrid.moveAllRowToGrid(rightGrid,0); //왼쪽 그리드의 모든 데이터를 오른쪽 그리드의 처음 로우로 내보내기
Parameters:
Name | Type | Description |
---|---|---|
toGrid |
number | 데이터를 내보낼 그리드 오브젝트 |
toRowIndex |
number | 이동될 곳의 로우 번호 |
Returns:
- Type
- undefined
(static) moveRow(start, end) → {undefined}
로우를 이동합니다
Example
grid.moveRow(0,1); //첫번째 로우를 두번째 로우위치로 이동
Parameters:
Name | Type | Description |
---|---|---|
start |
number | 이동할 로우 번호 |
end |
number | 이동될 곳의 로우 번호 |
Returns:
- Type
- undefined
(static) moveRowToGrid(toGrid, toRowIndex, rowIndexList) → {undefined}
사용자가 지정한 로우데이터를 다른 그리드로 내보냅니다
Example
var leftGrid = hg.hgrid({...}); //왼쪽그리드 생성
var rightGrid = hg.hgrid({...}); //오른쪽그리드 생성
leftGrid.moveRowToGrid(rightGrid,0,[0,1,2,3]); //왼쪽 그리드의 0,1,2,3번 데이터를 오른쪽 그리드의 처음 로우로 내보내기
Parameters:
Name | Type | Description |
---|---|---|
toGrid |
number | 데이터를 내보낼 그리드 오브젝트 |
toRowIndex |
number | 이동될 곳의 로우 번호 |
rowIndexList |
Array | 이동할 로우 번호 배열 |
Returns:
- Type
- undefined
(static) moveSelectedRowToGrid(toGrid, toRowIndex) → {undefined}
선택한 로우데이터를 다른 그리드로 내보냅니다
Example
var leftGrid = hg.hgrid({...}); //왼쪽그리드 생성
var rightGrid = hg.hgrid({...}); //오른쪽그리드 생성
leftGrid.moveSelectedRowToGrid(rightGrid,0); //왼쪽 그리드의 선택된 데이터를 오른쪽 그리드의 처음 로우로 내보내기
Parameters:
Name | Type | Description |
---|---|---|
toGrid |
number | 데이터를 내보낼 그리드 오브젝트 |
toRowIndex |
number | 이동될 곳의 로우 번호 |
Returns:
- Type
- undefined
(static) refresh(renderingFinishCallback) → {undefined}
데이터를 새로 로드합니다
Example
grid.refresh();
grid.refresh(function(){
alert('refresh complete');
});
Parameters:
Name | Type | Description |
---|---|---|
renderingFinishCallback |
function | refresh호출하고 화면이 다 그려진 호출되는 콜백 메소드 |
Returns:
- Type
- undefined
(static) saveEdit() → {undefined}
현재 수정중인 데이터를 저장합니다
Example
grid.saveEdit();//셀 내용 저장 후 닫기
grid.cancelEdit();
Returns:
- Type
- undefined
(static) setAllData() → {undefined}
모든 데이터를 한번에 설정합니다.
Example
var alldata = grid.getAllData();//모든데이터를 가져옵니다
alldata[0]['USER_SABUN'] = 'test';//일부를 수정합니다
grid.setAllData(alldata);//모든 데이터를 한번에 다시 설정합니다
Returns:
- Type
- undefined
(static) setCell(changeInfo) → {undefined}
셀의 데이터를 입력합니다
Example
grid.setCell([{rowid:0,columnid:'nm_cst',data:'2323123'}, {rowid:1,columnid:'nm_cst',data:'2323123'}]); // 첫번째 줄과 두번째 중의 'nm_cst' 컬럼에 'data'를 변경
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
changeInfo |
Array.<Object> | 변경정보
Properties
|
Returns:
- Type
- undefined
(static) setChecked(로우)
체크박스에 선택을 활성화 합니다
Example
grid.setChecked(0); //첫번째 로우에 체크박스 활성화
Parameters:
Name | Type | Description |
---|---|---|
로우 |
number | 번호 |
(static) setRow(changeInfo) → {undefined}
로우에 데이터를 입력합니다
Example
grid.setRow([{rowid:0, data:{nm_cst:'data1', nm_bar:'data2'}}, {rowid:1, data:{nm_cst:'data1', nm_bar:'data2'}}]);// 첫번째 줄과 두번째 줄의 두개 컬럼에 텍스트 설정
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
changeInfo |
Array.<Object> | 변경정보
Properties
|
Returns:
- Type
- undefined
(static) setTheme(theme) → {undefined}
그리드의 테마를 변경합니다
Example
grid.setTheme('basic_red');
Parameters:
Name | Type | Description |
---|---|---|
theme |
string | 테마이름 default, skyblue, oceanblue, bluishgreen, lightgreen, graypurple, pinkgray, darkgray, blackgray, claret, ict_theme, basic_red |
Returns:
- Type
- undefined
(static) showColumn(colunmId) → {undefined}
숨김컬럼을 다시 표시합니다
멀티헤더에서는 최하위 컬럼명에 대해서만 동작합니다
Example
grid.showColumn('USER_SABUN');
Parameters:
Name | Type | Description |
---|---|---|
colunmId |
string | 표시할 컬럼 아이디 |
Returns:
- Type
- undefined
(static) showRow(rowIndex) → {undefined}
숨겨진 로우를 표시합니다
Example
grid.showRow(0); //첫번째 로우 표시
Parameters:
Name | Type | Description |
---|---|---|
rowIndex |
number | 로우 번호 |
Returns:
- Type
- undefined