<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged select</title>
<link>https://overflow.efficy.io/?qa=tag/select</link>
<description>Powered by Question2Answer</description>
<item>
<title>How to activate Ajax call on select2 attached to a &lt;select&gt; element ?</title>
<link>https://overflow.efficy.io/?qa=6741/how-to-activate-ajax-call-on-select2-attached-select-element</link>
<description>&lt;p&gt;Dear all,&lt;/p&gt;

&lt;p&gt;I am trying to build a &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; with the &quot;select2&quot; component in order to search data from a Macro in a asynchronous mode because I am searching data to another entity. &lt;/p&gt;

&lt;p&gt;I now that in standard I can use the definition &lt;code&gt;LOOKUPDROPDOWNSEARCH&lt;/code&gt; but by doing so I forced to overwrite the &lt;code&gt;pages/dropdown/ListSearch.htm&lt;/code&gt; in order to pass the Macro I needed to load the data + I need to override the &lt;code&gt;editDetailCmd.js&lt;/code&gt; to pass this macro to the page. which is very not convenient.&lt;/p&gt;

&lt;p&gt;I wanted at first use the &lt;code&gt;&quot;data-ajax-url&quot;&lt;/code&gt; attribut, but it seems we are not allowed to do so on HTML &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; tag, at least with the select2 library version we have in Efficy Entreprise which is version 3.5.2. &lt;/p&gt;

&lt;p&gt;If we try to use it we got the following error : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;select2.js?ist=20221004215237&amp;amp;c=202210311518:947 Uncaught Error: Option 'ajax' is not allowed for Select2 when attached to a &amp;lt;select&amp;gt; element.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And I don't want to use an HTML &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; tag like it is used in standard for PostCode/City field since the value that I will store will be a key not a text.&lt;/p&gt;
</description>
<category>Efficy/ Client side</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=6741/how-to-activate-ajax-call-on-select2-attached-select-element</guid>
<pubDate>Mon, 31 Oct 2022 16:36:19 +0000</pubDate>
</item>
<item>
<title>Automatically select the tab of an activated category</title>
<link>https://overflow.efficy.io/?qa=4310/automatically-select-the-tab-of-an-activated-category</link>
<description>&lt;p&gt;When you activate a category, more than 9 times out of 10, you want to enter data for this category and you expect that Efficy will automatically select the corresponding tab for you.&lt;br&gt;
But Efficy doesn't. Do developpers really use the app? ;-)&lt;/p&gt;

&lt;p&gt;Since project team cares for their customers, here is a very simple code to implement this behavior.&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;pages\dialog\Category.htm&lt;/code&gt; file, call this function via &lt;code&gt;&amp;lt;body onload=&quot;storeInitialCategoriesByEditHandle()&quot;&amp;gt;&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function storeInitialCategoriesByEditHandle() {
  var elems = document.forms[0].elements,
  editHandle = &amp;lt; % GetEditHandle() % &amp;gt; ,
  categoriesKeys = [];

  for (var i = 0, len = elems.length; i &amp;lt; len; i++) {
    var e = elems[i];
    if (e.type === 'checkbox' &amp;amp;&amp;amp; e.checked)
      categoriesKeys.push(e.value);
  }

  if (opener.opener.initialCategoriesIndexedByEditHandle === undefined)
    opener.opener.initialCategoriesIndexedByEditHandle = [];

  opener.opener.initialCategoriesIndexedByEditHandle[editHandle] = categoriesKeys;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;From the start of the &lt;code&gt;js/main/edit.js&lt;/code&gt; call this function:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function checkNewCategory() {
  if (opener.initialCategoriesIndexedByEditHandle === undefined)
    return;

  var initialCategories = opener.initialCategoriesIndexedByEditHandle[Model(&quot;editHandle&quot;)];
  if (initialCategories === undefined)
    return;

  var $catgTabs = $(&quot;a[href^=#catg-]&quot;);
  for (var i = 0, length = $catgTabs.length; i &amp;lt; length; i++) {
    var catgTab = $catgTabs[i],
    hash = catgTab.hash,
    tableId = hash.substring(&quot;#catg-&quot;.length);
    if (parseInt(tableId) % 1000 === 0) // Ignore &quot;Fields&quot; pseudo category
      continue;
    if (initialCategories.indexOf(tableId) === -1) {
      $(catgTab).trigger(&quot;click&quot;);
    }
  }

  opener.initialCategories[Model(&quot;editHandle&quot;)] = undefined;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Any comment is welcome. Positive vote would be appreciated :-)&lt;/p&gt;
</description>
<category>Efficy/ Client side</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=4310/automatically-select-the-tab-of-an-activated-category</guid>
<pubDate>Tue, 21 May 2019 17:27:45 +0000</pubDate>
</item>
</channel>
</rss>