김태헌
김태헌

Reputation: 11

how to update dbids getting selection in autodesk aps

I follow this Tutorials " https://tutorials.autodesk.io/tutorials/dashboard/grid " I have done all of activities and I tried it out.

The "Data Grid" shows all of models data. But I want to show only "isolation has changed items dbids" (by clicking or filtering). of course, incase without selection, I do not want to show only selection but all.

I think update method should be changed on "DataGridPanel.js". But I am not sure. please help me

Regards,

/DataGridPanel.js

pdate(model, dbids) {
        model.getBulkProperties(dbids, { propFilter: DATAGRID_CONFIG.requiredProps }, (results) => {
            this.table.replaceData(results.map((result) => DATAGRID_CONFIG.createRow(result.dbId, result.name, result.properties)));
        }, (err) => {
            console.error(err);
        });
    }

/DataGridExtension.js

onModelLoaded(model) {
        super.onModelLoaded(model);
        if (this._panel && this._panel.isVisible()) {
            this.update();
        }
    }

    async update() {
        const dbids = await this.findLeafNodes(this.viewer.model);
        this._panel.update(this.viewer.model, dbids);
    }

Upvotes: 0

Views: 26

Answers (1)

Petr Broz
Petr Broz

Reputation: 9942

You can modify the DataGridExtension class like so:

class DataGridExtension extends BaseExtension {

    // ...

    async onSelectionChanged(model, dbids) {
        // When selection changes, update the datagrid panel
        super.onSelectionChanged(model, dbids);
        if (this._panel && this._panel.isVisible()) {
            this.update();
        }
    }

    async update() {
        // Show data for selected elements if there are any, otherwise show data for all "leaf" elements
        let dbids = this.viewer.getSelection();
        if (dbids.length === 0) {
            dbids = await this.findLeafNodes(this.viewer.model);
        }
        this._panel.update(this.viewer.model, dbids);
    }
}

Upvotes: 0

Related Questions