<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to optimize selectionManager.select(). Lags the system when selecting in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/How-to-optimize-selectionManager-select-Lags-the-system-when/m-p/4344316#M58820</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/905502"&gt;@Tung&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please change the codes as below and check if it can work better...&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;const handleClickSelectionVisual = useCallback((groupList: string[], parentRowList: { [key: string]: string | string[] }[]) =&amp;gt; {
  if (_.isEmpty(groupList) &amp;amp;&amp;amp; _.isEmpty(parentRowList)) {
    selectionManager.clear();
    return;
  }

  const rows = dataTableOrigin.rows || [];
  const dataParent = parentRowList.map(item =&amp;gt; item.rows) || [];
  const indices = filterDataGetIndices(dataParent as string[][], rows, groupList);

  // Using map instead of forEach for potential performance improvement
  const selectionList = indices.map((index: number) =&amp;gt; 
    selectionIdBuilder.createSelectionIdBuilder()
      .withTable(dataTableOrigin, index)
      .createSelectionId()
  );

  // Debouncing the select call to avoid frequent execution
  debounce(() =&amp;gt; {
    selectionManager.select(selectionList, false);
  }, 100); 
}, [selectionFilter, dataTableOrigin.rows]);

// Debounce function implementation
function debounce(func, wait) {
  let timeout;
  return function() {
    clearTimeout(timeout);
    timeout = setTimeout(() =&amp;gt; {
      func.apply(this, arguments);
    }, wait);
  };
}&lt;/LI-CODE&gt;
&lt;P&gt;Or you can raise the ticket in &lt;EM&gt;Custom Visuals Development Discussion forum&lt;/EM&gt; for a dedicated and professional support.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/bd-p/CustomVisualsDevelopmentDiscussion" target="_blank"&gt;Custom Visuals Development Discussion - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
    <pubDate>Fri, 27 Dec 2024 07:17:30 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-12-27T07:17:30Z</dc:date>
    <item>
      <title>How to optimize selectionManager.select(). Lags the system when selecting</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-optimize-selectionManager-select-Lags-the-system-when/m-p/4343335#M58809</link>
      <description>&lt;P&gt;My code has performance problem when selecting. It searches and returns index very fast. I return index to create "createSelectionIdBuilder" by index. but when it comes to the part of code that passes selectionList into select() "selectionManager.select(selectionList, false);" it slows down my system. Is there any way I can fix this problem. Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  const handleClickSelectionVisual = useCallback((groupList: string[], parentRowList: { [key: string]: string | string[] }[]) =&amp;gt; {
    if (_.isEmpty(groupList) &amp;amp;&amp;amp; _.isEmpty(parentRowList)) {
      selectionManager.clear()
      return;
    }

    const rows = dataTableOrigin.rows || [];
    const dataParent = parentRowList.map(item =&amp;gt; item.rows) || []
    const indices = filterDataGetIndices(dataParent as string[][], rows, groupList)

    const selectionList = []

    indices.forEach((index: number) =&amp;gt; {
      const selection = selectionIdBuilder.createSelectionIdBuilder()
        .withTable(dataTableOrigin, index)
        .createSelectionId();
      selectionList.push(selection);
    })

    selectionManager.select(selectionList, false);
  }, [selectionFilter, dataTableOrigin.rows])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2024 07:29:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-optimize-selectionManager-select-Lags-the-system-when/m-p/4343335#M58809</guid>
      <dc:creator>Tung</dc:creator>
      <dc:date>2024-12-26T07:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to optimize selectionManager.select(). Lags the system when selecting</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-optimize-selectionManager-select-Lags-the-system-when/m-p/4344316#M58820</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/905502"&gt;@Tung&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please change the codes as below and check if it can work better...&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;const handleClickSelectionVisual = useCallback((groupList: string[], parentRowList: { [key: string]: string | string[] }[]) =&amp;gt; {
  if (_.isEmpty(groupList) &amp;amp;&amp;amp; _.isEmpty(parentRowList)) {
    selectionManager.clear();
    return;
  }

  const rows = dataTableOrigin.rows || [];
  const dataParent = parentRowList.map(item =&amp;gt; item.rows) || [];
  const indices = filterDataGetIndices(dataParent as string[][], rows, groupList);

  // Using map instead of forEach for potential performance improvement
  const selectionList = indices.map((index: number) =&amp;gt; 
    selectionIdBuilder.createSelectionIdBuilder()
      .withTable(dataTableOrigin, index)
      .createSelectionId()
  );

  // Debouncing the select call to avoid frequent execution
  debounce(() =&amp;gt; {
    selectionManager.select(selectionList, false);
  }, 100); 
}, [selectionFilter, dataTableOrigin.rows]);

// Debounce function implementation
function debounce(func, wait) {
  let timeout;
  return function() {
    clearTimeout(timeout);
    timeout = setTimeout(() =&amp;gt; {
      func.apply(this, arguments);
    }, wait);
  };
}&lt;/LI-CODE&gt;
&lt;P&gt;Or you can raise the ticket in &lt;EM&gt;Custom Visuals Development Discussion forum&lt;/EM&gt; for a dedicated and professional support.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/bd-p/CustomVisualsDevelopmentDiscussion" target="_blank"&gt;Custom Visuals Development Discussion - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Fri, 27 Dec 2024 07:17:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-optimize-selectionManager-select-Lags-the-system-when/m-p/4344316#M58820</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-27T07:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to optimize selectionManager.select(). Lags the system when selecting</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-optimize-selectionManager-select-Lags-the-system-when/m-p/4345691#M58828</link>
      <description>&lt;P&gt;thanks, but that code doesn't solve the problem&lt;/P&gt;</description>
      <pubDate>Mon, 30 Dec 2024 01:58:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-optimize-selectionManager-select-Lags-the-system-when/m-p/4345691#M58828</guid>
      <dc:creator>Tung</dc:creator>
      <dc:date>2024-12-30T01:58:13Z</dc:date>
    </item>
  </channel>
</rss>

