Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anurag2
Contributor II
Contributor II

Get current selection with @qlik/embed-react

I have used @qlik/embed-react to embed qlik cloud in reactjs and i want to get current selection in my reactJS app. 
i am embedding selection bar using below code 

<QlikEmbed  ui="analytics/selections" appId={appId} />

and getting app instance using QlikEmbedConfig context
 
  const hostConfig = useContext(QlikEmbedConfig);
  const app = useApp(appId, hostConfig);
 
and also have a hook useApp :

export const useApp = (appId, hostConfig) => {
  const [app, setApp] = useState(null);

  useEffect(() => {
    const getApp = async () => {
      const session = qix.openAppSession({ appId, hostConfig });
      const doc = await session.getDoc();
      setApp(doc);
    };
    if (hostConfig) {
     return app;
    }
  }, [appId, hostConfig]);

  return app;
};


can anyone please help me how i get selection/filters values for current sheet
Anurag2_0-1733298639136.png

Please help me here.



2 Replies
vijaya6
Contributor II
Contributor II

Hi , 
are you using Qlik cloud platform or enterprise edition ?

 

chad
Employee
Employee

I just came across your post.  I don't know if you've accomplished your goal, but to build on your own example, you can get the current selections like this:

const app = useApp(appId, hostConfig)
const getSelections = async(app) => {
  const selectionsObj = await app.getCurrentSelectionObject();
  const selectionsLayout = await currentSelection.getLayout();
  return selectionLayout.qSelectionObject?.qSelections);
}


You can also set selectionsObj.on('changed', ... and fetch the new layout when selections change