React Tree Grid Row Editing
The Ignite UI for React Row Editing feature in React Tree Grid allows editing data directly within the IgrTreeGrid. On top of this convenient way to manipulate data, there’s a powerful API for full CRUD operations. You can perform grid row editing by clicking on a row and pressing Enter key. Another quick way is to double click with the mouse on the row that needs to be modified.
React Tree Grid Row Editing Example
The following sample demonstrates how to enable row editing in the IgrTreeGrid. Changing a cell value and then clicking or navigating to another cell on the same row won't update the row value until confirmed by using the Done button, or discarded by using Cancel button.
[!Note] When a row is in edit mode, clicking on a cell in another row will act like the "Done" button is pressed, submitting all changes made in the previous row. If the newly focused cell is editable, the new row enters edit mode as well. However, if the cell is not editable, only the previous row exits edit mode.
Row Editing Usage
Define a IgrTreeGrid with bound data source and rowEditable set to true:
<IgrTreeGrid primaryKey="ID" width="100%" height="500px" rowEditable={true}>
<IgrColumn field="Name" header="Name" dataType="string"></IgrColumn>
<IgrColumn field="Age" header="Age" dataType="number"></IgrColumn>
<IgrColumn field="Title" header="Title" dataType="string"></IgrColumn>
<IgrColumn field="HireDate" header="Hire Date" dataType="date"></IgrColumn>
</IgrTreeGrid>
[!Note] Setting primary key is mandatory for row editing operations.
[!Note] Enabling editing for individual columns is not necessary. Using the
rowEditableproperty in theIgrTreeGrid, all rows, with definedfieldproperty (excluding the primary row) will be editable. If you want to disable editing for a specific column, simply set theeditableinput of that column tofalse.
[!Note] The
IgrTreeGridutilizesBaseTransactionService- an internal provider that holds pending cell changes until the row state is either submitted or cancelled.
Positioning
오버레이의 기본 위치는 편집 모드에 있는 행 아래에 있습니다.
행 아래에 공간이 없으면 행 위에 오버레이가 나타납니다.
상단 또는 하단에 표시된 오버레이는 오버레이가 닫힐 때까지 스크롤하는 동안 이 위치를 유지합니다.
Behavior
행이 편집 모드인 경우 동일한 행의 셀을 클릭하면 편집이 계속됩니다.
"완료" 버튼을 클릭하면 행 편집이 완료되고 데이터 소스 또는 가능한 경우 트랜잭션에 변경 사항이 제출됩니다. 또한 행은 편집 모드를 종료합니다.
"취소" 버튼을 클릭하면 행의 현재 변경 사항이 모두 되돌려지고 행은 편집 모드를 종료합니다.
행이 편집 모드인 경우 다른 행의 셀을 클릭하면 현재 행 편집이 완료되고 새 행 변경 사항이 제출됩니다("완료" 버튼을 클릭하는 것과 동일한 동작). 포커스를 받은 새 셀이 편집 가능하면 새 행도 편집 모드로 들어가고, 셀을 편집할 수 없으면 이전 행만 편집 모드에서 나갑니다.
If row is in edit mode and
IgrTreeGridis scrolled so that row goes outside the visible area, the latter will be still in edit mode. WhenIgrTreeGridis scrolled, so that the row is visible again, the row will be still in edit mode. When clicked outside theIgrTreeGrid, the cell will also stay in edit mode.정렬, 필터링, 검색 및 숨기기 작업을 수행하면 행의 모든 현재 변경 사항이 되돌리고, 행은 편집 모드를 종료합니다.
페이징, 크기 조정, 고정 및 이동 작업을 수행하면 편집 모드를 종료하고 최신 값을 제출합니다.
Each modified cell gets edited style until row edit is finished. This is the behavior, when
IgrTreeGridis not provided with transactions. When transactions are available - then cell edit style is applied until all the changes are committed.
Keyboard Navigation
ENTER 행 F2 편집 모드로 들어갑니다.
ESC 행 편집 모드를 종료하고 행이 편집 모드에 있는 동안 수행된 셀 변경 사항을 제출하지 않습니다.
Tab 키를 누르면 행의 편집 가능한 한 셀에서 다음 셀로, 가장 오른쪽의 편집 가능한 셀에서 CANCEL 및 DONE 버튼으로 초점을 이동합니다. 완료 버튼을 통한 탐색은 현재 편집된 행 내에서 편집 가능한 가장 왼쪽 셀로 이동합니다.
Feature Integration
모든 데이터 변경 작업은 행 편집 작업을 종료하고 현재 행 변경 사항을 제출합니다. 여기에는 정렬, 그룹화 및 필터링 기준 변경, 페이징 등과 같은 작업이 포함됩니다.
행 편집이 완료된 후 요약이 업데이트됩니다. 정렬, 필터링 등과 같은 다른 기능에도 동일하게 적용됩니다.
Customizing Row Editing Overlay
Customizing Text
템플릿을 사용하여 행 편집 오버레이의 텍스트를 사용자 정의할 수 있습니다.
The RowChangesCount property is exposed and it holds the count of the changed cells.
const rowEditTextTemplate = (ctx: IgrGridRowEditTextTemplateContext) =>{
return (
<>
Changes: {ctx.implicit}
</>
);
}
Customizing Buttons
템플릿을 통해 행 편집 오버레이의 버튼을 사용자 정의할 수도 있습니다.
const rowEditActionsTemplate =(ctx: IgrGridRowEditActionsTemplateContext) => {
const endRowEdit = ctx.implicit;
return (
<>
<button onClick={(event) => endRowEdit(false, event)}>Cancel</button>
<button onClick={(event) => endRowEdit(true, event)}>Apply</button>
</>
);
}
Styling
사전 정의된 테마 외에도 사용 가능한 CSS 속성 중 일부를 설정하여 그리드를 추가로 사용자 정의할 수 있습니다. 일부 색상을 변경하려면 먼저 그리드에 대한 클래스를 설정해야 합니다.
<IgrTreeGrid className="grid"></IgrTreeGrid>
그런 다음 해당 클래스에 대한 관련 CSS 속성을 설정합니다.
.grid {
--ig-banner-banner-background: #e3e3e3;
--ig-banner-banner-message-color: #423589;
}
Demo
Known Issues and Limitations
그리드에 세트가 없
primaryKey고 원격 데이터 시나리오가 활성화되어 있을 때(페이징, 정렬, 필터링, 스크롤 시 원격 서버에 표시할 데이터를 가져오기 요청이 트리거될 때), 데이터 요청이 완료된 후 다음 상태가 줄로 사라집니다:행 선택
행 확장/축소
행 편집
행 고정
API References
rowEditableRowEditEnterRowEditRowEditDoneendEditfieldeditableprimaryKeyIgrTreeGrid
Additional Resources
우리 커뮤니티는 활동적이며 항상 새로운 아이디어를 환영합니다.