User Tools

Site Tools


Plugin installed incorrectly. Rename plugin directory 'swiftmail.backup' to 'swiftmail'.
en:software:tim:smartform:autocomplete

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:software:tim:smartform:autocomplete [2018/04/18 09:14]
Julian Le created
en:software:tim:smartform:autocomplete [2021/07/01 09:52] (current)
Line 1: Line 1:
-FIXME **This page is not fully translated, yet. Please help completing the translation.** \\ +==== Autocomplete ​function ​in the smartform ​====
-//(remove this paragraph once the translation is finished)//​ +
-==== Autocomplete ​Funktion ​in der Smartform ​====+
  
-Eine Autocomplete Funktion ist eine Funktiondie bei Eingabe in ein Textfeld Vorschläge gibt welche dann ausgewählt werden könnenEin Beispiel wäre ein Feld für die Auswahl eines Mitarbeiters.+A autocomplete function is a functionthat, when inputting into a textfield, makes suggestions,​ which then can be selectedAn example would be a field for selecting a employee.
  
 === jQuery === === jQuery ===
  
-Für den ersten Schritt muss die Javascript Bibliothek ​jQuery ​eingebunden werdenDiese beinhaltet bereits einfach Möglichkeiten zur Einbindung von Autocomplete FunktionenDie Einbindung muss in der initMethod ​der Smartform geschehendamit jQuery ​zu jederzeit verfügbar istDie Einbindung erfolgt über die folgenden Zeile:+For the first step the JavaScript library ​jQuery ​has to be integratedThis already contains possibilities for integrating autocomplete functionsThe integration has to happen ​in the initMethod ​of the smartformso that jQuery ​is available at all timesThe integration occurs via the following line:
  
 <code javascript>​ <code javascript>​
Line 13: Line 11:
 </​code>​ </​code>​
  
-Der "​$" ​Operator ist nun über den "​jq" ​Operator verfügbar und ist nötig um jQuery ​Funktionaliäten benutzen zu können.+The "​$" ​operator is now available as the "​jq" ​operator and is needed to use jQuery ​functionalties.
  
 === Autocomplete === === Autocomplete ===
  
-Jeder beliebige Textfeld kann nun ausgewählt werden um einen Autocomplete zu beinhaltenHierfür muss das Feld über einen sogenannten Selektor gefunden werdenEin Feld kann mit Hilfe seiner ​ID über die folgenden Zeile gefunden werden:+Any textfield can now be selected to include a autocompleteTHerefor the field has to be found via a selectorA field can be found by its ID via the following line:
  
 <code javascript>​ <code javascript>​
-jq('#ID_DES_FELDES');+jq('#ID_OF_FIELD');
 </​code>​ </​code>​
  
-Die erste Ausbaustufe des Autocomplete wird an Hand eines einfachen Beispiels erötertHierbei wird dem Feld ein Autocomplete aufgesetztwelchem ein sogenannter Array (stellt eine Liste von Werten darals Quelle dient.+The first extension stage will be shown with a simple exampleHere the autocomplete is put on the fieldwhereby an array (describes a list of valuesis used as a source.
  
 <code javascript>​ <code javascript>​
-jq( "#ID_DES_FELDES" ).autocomplete({+jq( "#ID_OF_FIELD" ).autocomplete({
         source: [ "​Example 1", "​Example 2", "​Example 3", "​Example 4", "​Example 5"]         source: [ "​Example 1", "​Example 2", "​Example 3", "​Example 4", "​Example 5"]
 }); });
Line 33: Line 31:
 {{  :​software:​tim:​smartform_basics:​autocomplete_first_example.png?​1200 ​ }} {{  :​software:​tim:​smartform_basics:​autocomplete_first_example.png?​1200 ​ }}
  
-Im nächsten Schritt muss diese Funktion nun erweitert werdensodass die Auswahl die getroffen wird auch gespeichert wirdHierfür muss der Code folgendermaßen angepasst werdenEs muss eine '​change' ​Funktion hinzugefügt werden welche bei Auswahl einer Vorschlagsmöglichkeit aufgerufen wird. In dieser Methode wird nun der so genannten ​'​entity' ​der Name und der Wert des Inputfeldes gegebenNun ist es T!M möglich diese Prozessvariable abzuspeichernIn der change ​Methode ist es ebenfalls möglich eine Validierung einzubauen die überprüft ob eine Auswahl getroffen wurde.+In the next step the function has to be extendedso that the selected option is saved as wellTherefor the code has to be adjusted as follows'​change' ​function has to be added, which is called when selection an option. In this method the nam and value is passed on to the so-called ​'​entity'​. ​Now it is possible for TIM to save the processvariableIt is also possible to include a valdiate function in the change ​method, that checks, if a selection was made.
  
 <code javascript>​ <code javascript>​
Line 49: Line 47:
 </​code>​ </​code>​
  
-Für das Autocomplete können nun noch zusätzliche Parameter eingestellt werdenUm das Beispiel weiter auszubauenfügen wir hinzu dass erst ab einer Länge von Zeichen der Eingabe die Vorschläge angezeigt werdenDies hat vor allem bei großen Datensätzen den Vorteil dass die Auswahlliste nicht übermäßig lang wirdUm diese zu realisieren fügen wir die Einstellung ​"​minLength" ​hinzuWeiter Parameter können ​in der [[http://​api.jqueryui.com/​autocomplete/​|API]] ​von jQuery ​eingesehen werden.+Additional parameter can be set for the autocompleteTo expand the exmaplewe add that suggestions will only be shown after inputting ​charactersThis has the advantage that when using a large data set the suggestion list is not too longTo implement this we add the setting ​"​minLength"​. ​Additional paramters can be seen in the [[http://​api.jqueryui.com/​autocomplete/​|API]] ​of jQuery
  
 <code javascript>​ <code javascript>​
Line 66: Line 64:
 </​code>​ </​code>​
  
-=== Autocomplete ​mit CSV Datei als Quelle ​===+=== Autocomplete ​with CSV file as source ​===
  
-Die Vorschläge für das Autocomplete können natürlich auch komplexer sein und mehrere Informationen enthaltenHierfür muss dem Autocomplete zum Beispiel ein Textfile übergebenFür dieses Beispiel benutzen wir eine Beispieldatei mit PersonaldatenDiese enthält VornamenNachnamenEmail und Telefonnummer ​in den einzelnen Spalte der CSV. Die Datei liegt in dem Beispiel im Custom OrdnerZuerst muss diese Datei geholt werden und ein Objekt aus dessen Inhalten erzeugt werdenDies geschieht per AJAX RequestDer Inhalt der Datei wird zuerst an jedem Zeilenumbruch geteilt und anschließend an jedem SemikolonEs wird nun also ein Objekt ​employee" ​mit den Daten aus der Textdatei generiertDas Objekt employee wird nun als Source dem Autocomplete übergebenIm Falle einer Auswahlwird VornameNachnameEmail und Telefonnummer ​in einem Popup ausgegebenKann das Textfile nicht geladen werden wird eine Fehlermeldung ausgegeben.+The suggestions for the autocomplete can of course be more complexe and include more informationTherefor the autocomplete has to be passed a text fileFor this example we are using a example file with personnel dataIt contains first namelast nameemail and phonenumber ​in the columns of the CSV. The file is located ​in this exmaple in the custom folderFirstly the file has to be called and a object has to be created from the contentThis happens via AJAX requestThe file's content will be split on ever linebreak and then on ever semicolonNow an object "employee" ​with data from the text file is generatedThe object is then passed on to the autocomplete as a sourceIf an option is selectedfirst namelast nameemail and phonenumber are displayed ​in a popupIf the text file cannot be loaded, an error message is shown.
  
 <code javascript>​ <code javascript>​
Line 88: Line 86:
                 };                 };
             }             }
-            jq( "#ID_DES_INPUTFELDES" ).autocomplete({+            jq( "#ID_OF_FIELD" ).autocomplete({
                 source: employees,                 source: employees,
                 minLength: 0,                 minLength: 0,
en/software/tim/smartform/autocomplete.1524035684.txt.gz · Last modified: 2021/07/01 09:54 (external edit)