Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Shadi_Sai
Contributor III
Contributor III

Export to csv only selected object from within container object

Greetings everyone,
I have a container object that has 3 tables inside, am trying to export only the selected table to csv, however currently its exporting all the object under the container which is the 3 tables, I know the reason for that is because its inside a for loop on the objects of the container, however my question is how can I get only the active object from inside the container?
I found another post mentioning "app.getFullPropertyTree" however am not sure how to use it.
Is there a way to tell which object is currently selected inside the container, then passign that objectID to the export csv funtion?

my current code:
app.visualization.get('TjAb').then(async function (vis) {
    vis.show("QV01");
    visList.push(vis);
    const mainId = vis.id;
    const containerLayout = await vis.model.getLayout();
    const childObjects = Object.values(containerLayout.qChildList);
    for (const child of childObjects) {
        for (const item of child)
            {
                 const objectexport = await app.visualization.get(item.qInfo.qId);
                 attachExportEvent(mainId, objectexport, item.qInfo.qId);
            }
    }
});


function attachExportEvent(mainId ,object, objectId) {
     $(`#buttonID`+ mainId).click(async function () {
             activeObject = object;
             console.log("exporting object " + activeObject);
             if (activeObject) {
                    activeObject.exportData({ format: 'CSV_C', state: 'A' }).then(function (link) {
                    window.open(link);
                  });
               }
        });
}


Labels (2)
1 Solution

Accepted Solutions
alex_colombo
Employee
Employee

Hi @Shadi_Sai , in the containerLayout constant you have all the information that you need. If you look you have a props called activeTab where you have an ID. This ID is also defined under qChildList --> qItems array. There you will find all your container visualizations and then one with the ID present in activeTab is the active one.

View solution in original post

2 Replies
alex_colombo
Employee
Employee

Hi @Shadi_Sai , in the containerLayout constant you have all the information that you need. If you look you have a props called activeTab where you have an ID. This ID is also defined under qChildList --> qItems array. There you will find all your container visualizations and then one with the ID present in activeTab is the active one.

Shadi_Sai
Contributor III
Contributor III
Author

Thank You @alex_colombo ,
I didn't notice the activeTab props before, I have updated the code using it and now its working good.