Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
815
igx-hierarchical-grid Data Disappears within nested grid
posted

We have a Service calling a Webapi method after a while the child grid data is no longer bound. Is there something I am missing in my grid.

import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { Observable } from "rxjs";
import { map } from "rxjs/operators";

interface IoDataResponse {
value: any[];
}

export interface IDataState {
key: string;
parentID: any;
parentKey: string;
rootLevel: boolean;
}

@Injectable()
export class RemoteLoDService {
public url = 'localhost:44392/.../SalesmanJobInfo';
constructor(private http: HttpClient) { }

public getData(dataState?: IDataState): Observable<any> {
return this.http.get(this.buildUrl(dataState));
}

public buildUrl(dataState: IDataState) {
// let qS = "";
// if (dataState) {
// qS += `${dataState.key}?`;

// if (!dataState.rootLevel) {
// if (typeof dataState.parentID === "string") {
// qS += `$filter=${dataState.parentKey} eq '${dataState.parentID}'`;
// } else {
// qS += `$filter=${dataState.parentKey} eq ${dataState.parentID}`;
// }
// }
// }
return `${this.url}`;
}
}

 

<div class="grid__wrapper">
<igx-hierarchical-grid #hGrid [primaryKey]="'JobInfoID'" [autoGenerate]="false" [height]="'600px'" [width]="'1390px'" [allowFiltering]="true">
<igx-column field="JobInfoID" [hidden]="true" [dataType]="'number'"></igx-column>
<igx-column field="JobNumber" header="Job Number" [editable]="false" [dataType]="'string'"></igx-column>
<igx-column field="JobName" header="Job Name" [editable]="true" [dataType]="'string'"></igx-column>
<igx-column field="ClientName" header="Client Name" [editable]="true" [dataType]="'string'"></igx-column>
<igx-column field="StartDate" header="Start Date" [editable]="true" [dataType]="'date'"></igx-column>
<igx-column field="Status" header="Status" [editable]="true" [dataType]="'string'"></igx-column>
<igx-row-island [key]="'Floors'" [autoGenerate]="false" (onGridCreated)="gridCreated($event, 'JobInfoFloorID')" [width]="'100%'">
<igx-column field="JobInfoFloorID" [hidden]="true" [dataType]="'number'"></igx-column>
<igx-column field="Sequence" header="Sequence" [editable]="true" [dataType]="'number'"></igx-column>
<igx-column field="FloorName" header="Floor" [editable]="true" [dataType]="'string'"></igx-column>
<igx-column field="Area" header="Area" [editable]="true" [dataType]="'number'"></igx-column>
<igx-column field="StartDate" header="Start Date" [editable]="true" [dataType]="'date'"></igx-column>
<igx-column field="LinearFootHandrail" header="LF Handrail" [editable]="true" [dataType]="'number'"></igx-column>
<igx-column field="ClearStoryHeight" header="C.S.H" [editable]="true" [dataType]="'string'"></igx-column>
<igx-column field="Days" header="Days" [editable]="true" [dataType]="'number'"></igx-column>
<igx-column field="LinearFootBeam" header="L.F. Beam" [editable]="true" [dataType]="'number'"></igx-column>
<igx-column field="LinearFootHandrail" header="L.F. Beam" [editable]="true" [dataType]="'number'"></igx-column>
<igx-column field="NoOfDrops" header="# Drops" [editable]="true" [dataType]="'number'"></igx-column>
</igx-row-island>
</igx-hierarchical-grid>
</div>
import { AfterViewInit, Component, ViewChild } from "@angular/core";
import {
IGridCreatedEventArgs,
IgxHierarchicalGridComponent,
IgxRowIslandComponent
} from "igniteui-angular";
import { IDataState, RemoteLoDService } from "../salesgridui/services/TOD.service";

@Component({
providers: [RemoteLoDService],
selector: "salesgridui",
styleUrls: ["./salesgridui.component.scss"],
templateUrl: "./salesgridui.component.html"
})
export class SalesGridUIComponent implements AfterViewInit {
@ViewChild("hGrid", { static: true })
public hGrid: IgxHierarchicalGridComponent;

constructor(private remoteService: RemoteLoDService) { }

public ngAfterViewInit() {
const dataState: IDataState = {
key: "JobInfoFullCollection",
parentID: "",
parentKey: "",
rootLevel: true
};
this.hGrid.isLoading = true;
this.remoteService.getData(dataState).subscribe(
(data) => {
this.hGrid.isLoading = false;
this.hGrid.data = data;
this.hGrid.cdr.detectChanges();
},
(error) => {
this.hGrid.emptyGridMessage = error.message;
this.hGrid.isLoading = false;
this.hGrid.cdr.detectChanges();
}
);
}

public dateFormatter(val: string) {
return new Intl.DateTimeFormat("en-US").format(new Date(val));
}

public gridCreated(event: IGridCreatedEventArgs, _parentKey: string) {
const dataState: IDataState = {
key: event.owner.key,
parentID: event.parentID,
parentKey: _parentKey,
rootLevel: false
};
event.grid.isLoading = true;
this.remoteService.getData(dataState).subscribe(
(data) => {
event.grid.isLoading = false;
event.grid.data = data;
event.grid.cdr.detectChanges();
},
(error) => {
event.grid.emptyGridMessage = error.message;
event.grid.isLoading = false;
event.grid.cdr.detectChanges();
}
);
}
}

Parents Reply
  • 815
    Offline posted in reply to Maya Kirova

    Hello Maya,

    Looks like the Web API Method is accessible outside of our network:

    http://toddev.titanformwork.com/SalesmanJobInfo/GetJobInfoFull

    The JSON looks like the following:

    {
        "data": [{
                "JobInfoID": 289,
                "SequenceNumber": 0,
                "JobNumber": "710418019 ",
                "JobName": "314 Pennsylvania Avenue",
                "BusinessUnitID": 0,
                "ClientName": null,
                "StatusName": "Pending Assignment",
                "BookedUnbookedArchivedStatus": "Booked",
                "StartDate": "\/Date(-62135575200000)\/",
                "StartDateASISO8601": "2018-02-25T00:00:00Z",
                "GrossBuildingArea": 22720,
                "Total": 22110.000,
                "PrimarySalesmanName": "Paul Tauscher",
                "BidDate": "\/Date(-62135575200000)\/",
                "BidDateASISO8601": "2018-02-02T00:00:00Z",
                "Phase": null,
                "FreightRate": null,
                "EngineeringHours": 0,
                "DetailerHours": 0,
                "PrimaryEngineerName": null,
                "Remark": null,
                "NoOfFloor": 9,
                "PercentageShipped": null,
                "PrimaryCADTeamLead": null,
                "SecondaryCADTeamLead": null,
                "PrimaryDetailer": null,
                "SecondaryDetailer": null,
                "PDFFile": null,
                "ClientBusinessUnitID": 2200,
                "BusinessName": "Triborough Construction Services, Inc.",
                "JobInfoFloors": [{
                        "JobInfoFloorID": 902,
                        "JobInfoID": 0,
                        "Name": "Roof",
                        "FloorType": "test",
                        "NetAreaInSqFt": 1655,
                        "FurnishAreaInSqFt": null,
                        "LinearFootHandrail": 95,
                        "LinearFootBeamInternal": 40,
                        "LinearFootBeamSpandrel": null,
                        "NoOfDropsPerSqFt": 0,
                        "ClearStoryHeight": "9\u0027-8\"",
                        "Discount": null,
                        "StartDate": "\/Date(-62135575200000)\/",
                        "StartDateISO3061": null,
                        "EstimatedStartDate": null,
                        "CompletionDate": null,
                        "SequenceNumber": 9,
                        "ShipOutInDay": null,
                        "WorkingDurationInDay": 5,
                        "IsCurrentFloor": null,
                        "IsTemplate": null,
                        "Description": null,
                        "CreatedOn": null,
                        "CreatedBy": null,
                        "UpdatedBy": null,
                        "UpdatedOn": null,
                        "StatusID": null,
                        "StatusName": null,
                        "Comment": "",
                        "SlabDepth": null,
                        "Shores": null,
                        "ShoreOptions": null,
                        "ShoreCSV": "#3 Post Shore"
                    }
                ]
            }
    }

Children