Skip to content

Commit

Permalink
feat: data count to hosting app (#848)
Browse files Browse the repository at this point in the history
* feat: add function that sets the length of data in hosting app

* fix: check for function

Co-authored-by: Johan Lahti <johanlahti@users.noreply.github.com>

Co-authored-by: Johan Lahti <johanlahti@users.noreply.github.com>
  • Loading branch information
DanielS-Qlik and johanlahti committed Jun 8, 2022
1 parent 61a2803 commit 3907480
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apis/nucleus/src/components/listbox/ListBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default function ListBox({
scrollState,
sortByState,
selectDisabled = () => false,
setCount,
}) {
const [layout] = useLayout(model);
const isSingleSelect = !!(layout && layout.qListObject.qDimensionInfo.qIsOneAndOnlyOne);
Expand Down Expand Up @@ -187,6 +188,9 @@ export default function ListBox({

useEffect(() => {
fetchData();
if (typeof setCount === 'function' && layout) {
setCount(layout.qListObject.qSize.qcy);
}
}, [layout]);

useEffect(() => {
Expand Down
2 changes: 2 additions & 0 deletions apis/nucleus/src/components/listbox/ListBoxInline.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default function ListBoxInline({ app, fieldIdentifier, stateName = '$', o
showGray = true,
sortByState = 1,
scrollState = undefined,
setCount = undefined,
} = options;
let { frequencyMode, histogram = false } = options;

Expand Down Expand Up @@ -341,6 +342,7 @@ export default function ListBoxInline({ app, fieldIdentifier, stateName = '$', o
showGray={showGray}
scrollState={scrollState}
sortByState={sortByState}
setCount={setCount}
/>
)}
</AutoSizer>
Expand Down
1 change: 1 addition & 0 deletions apis/nucleus/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const mergeConfigs = (base, c) => ({
* @property {ReceiverFunction} [options.update] A function which receives an update function which upon call will trigger a data fetch.
* @property {{setScrollPos:function(number):void, initScrollPos:number}} [options.scrollState=] Object including a setScrollPos function that sets current scroll position index. A initial scroll position index.
* @property {number=} [options.sortByState=1] Sort by state, detault 1 = sort descending, 0 = no sorting, -1 sort ascending.
* @property {function(number):void} [options.setCount=] A function that gets called with the length of the data in the Listbox.
*/

/**
Expand Down

0 comments on commit 3907480

Please sign in to comment.