2017-10-27 21 views

답변

0

는 NG 템플릿 요소 검도 내에서만큼 당신이 발생하지 않는 한 이 그리드의 선택 속성이 true로 설정되어있는 경우, 트리거하는를 SelectionChange 이벤트 그러나, 그리고, 슬프게도 그런 이벤트가 없습니다 명시 적 모델로 다시 값을 기록하고 수동 여부를 돌볼 때까지, 같은

<ng-template kendoGridCellTemplate let-dataItem> 
    <input type="checkbox" [checked]="dataItem.Dropped?true:false" (click)="DroppedClicked($event, dataItem)" /> 
</ng-template> 

로 -grid 열 요소는 이러한 템플릿은 편집 모드에 통합되지 않으며, 사용자 상호 작용은 존중되지 않습니다 그 셀은 이전과 다른 행에있었습니다! 다른 경우에는 selectionChange 이벤트에 의존 할 수 있습니다.이 이벤트는 사용자가 다른 행의 컨트롤을 활성화 할 때 트리거됩니다.

위의 템플릿의 입력 요소에서 행 변경을 확인하려면, 클릭 이벤트가 이벤트 변수와 DroppedClicked - 이벤트 핸들러에있는 DataItem을 모두 통과하고, 그 핸들러가이 작업을 수행 :

public DroppedClicked(event, dataItem): void 
{ 
    let rowIndex = event.currentTarget.parentNode.parentNode.rowIndex; 
    let arg = { crtlKey: null, deselectedRows: [this.currentRow], index: rowIndex, selected: true, selectedRows: [dataItem] }; 
    if (rowIndex != this.currentRowIndex) // row has changed 
     this.onRowChange(arg); 
    dataItem.Dropped = event.target.checked ? 1 : 0; 
} 

곳 onRowChange (...) 그리드의 HTML 템플릿에 등록를 SelectionChange 이벤트에 대한 이벤트 처리기입니다 :

<kendo-grid projectAssignmentBinding [pageSize]="30" 
      [pageable]="true" [filterable]="true" [selectable]="true" (selectionChange)="onRowChange($event)" 
      [sortable]="true" [height]="500" editable="true" 
      (cellClick)="onEditCell($event)" (cellClose)="onCellClose($event)" > 
    ... 
</kendo-grid> 

는 그 핸들러이 수행합니다

saveRow()는 this.currentRow를 저장하고 this.IsDirtyRow를 false로 재설정합니다.

가장 많이 들었던 것은 편집 모드가 cellClick 및 cellClose 이벤트에서 formGroup을 시작 및 끝내는 것에 의존한다는 것입니다. cellClose가 게시하지 않기 때문에 cellClick이 열에 관계없이 cellGroup이 새 formGroup을 시작해야합니다. $ 이벤트의 columnIndex를 반환하고 전체 formGroup을 모두 닫습니다.