Skip to content

Commit

Permalink
fix(extension): Row Detail gets blanked out for no reason, fixes #546 (
Browse files Browse the repository at this point in the history
…#552)

- it seems that when trying to find the DOM element of the row detail, we should always use the last one instead of the first one found
- final fix for issue #546
  • Loading branch information
ghiscoding committed Aug 3, 2020
1 parent 324f490 commit 0087dd2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/app/examples/grid-rowdetail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core';
import {
AngularGridInstance,
Column,
ExtensionName,
FieldType,
Filters,
Formatters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,24 +243,24 @@ export class RowDetailViewExtension implements Extension {
/** Redraw the necessary View Component */
redrawViewComponent(createdView: CreatedView) {
const containerElements = document.getElementsByClassName(`${ROW_DETAIL_CONTAINER_PREFIX}${createdView.id}`);
if (containerElements && containerElements.length) {
if (containerElements && containerElements.length >= 0) {
this.renderViewModel(createdView.dataContext);
}
}

/** Render (or rerender) the View Component (Row Detail) */
renderPreloadView() {
const containerElements = document.getElementsByClassName(`${PRELOAD_CONTAINER_PREFIX}`);
if (containerElements && containerElements.length) {
this.angularUtilService.createAngularComponentAppendToDom(this._preloadComponent, containerElements[0], true);
if (containerElements && containerElements.length >= 0) {
this.angularUtilService.createAngularComponentAppendToDom(this._preloadComponent, containerElements[containerElements.length - 1], true);
}
}

/** Render (or rerender) the View Component (Row Detail) */
/** Render (or re-render) the View Component (Row Detail) */
renderViewModel(item: any): CreatedView | null {
const containerElements = document.getElementsByClassName(`${ROW_DETAIL_CONTAINER_PREFIX}${item[this.datasetIdPropName]}`);
if (containerElements && containerElements.length) {
const componentOutput = this.angularUtilService.createAngularComponentAppendToDom(this._viewComponent, containerElements[0], true);
if (containerElements && containerElements.length > 0) {
const componentOutput = this.angularUtilService.createAngularComponentAppendToDom(this._viewComponent, containerElements[containerElements.length - 1], true);
if (componentOutput && componentOutput.componentRef && componentOutput.componentRef.instance) {
// pass a few properties to the Row Detail template component
Object.assign(componentOutput.componentRef.instance, {
Expand Down

0 comments on commit 0087dd2

Please sign in to comment.