scripting:dialogs:multi_listbox

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
scripting:dialogs:multi_listbox [2015/01/20 01:15] – [Dynamic content] adminscripting:dialogs:multi_listbox [2018/01/10 20:41] (current) – external edit 127.0.0.1
Line 15: Line 15:
  
 ===== Items ===== ===== Items =====
-List Box is filled by //Items//You can fill it statically in-line OR dynamically using associated by //id// script variable (VB Array of integers, use [[scripting:dialogs:ax2js|ax2js]] function to convert from JS array). If you pass dynamic content and define static selection, static one is ignored.+List Box is filled by //Items//Initial selection state for items can be set statically in-line or dynamically using associated by //id// script variable (VB Array of integers, use [[scripting:dialogs:ax2js|ax2js]] function to convert from JS array). If you pass dynamic content and define static selection, static one is ignored.
  
 ==== Item ==== ==== Item ====
Line 95: Line 95:
 Creating content dynamically is not straightforward, but possible by generating of the static template in script. Creating content dynamically is not straightforward, but possible by generating of the static template in script.
  
-<file javascript multi-list-box.hejs>+<file javascript multi-list-box-dynamic-content.hejs>
 #include "he_utils.js" // this is include file #include "he_utils.js" // this is include file
    
Line 101: Line 101:
  
 var dialog_template = var dialog_template =
-'<dialog title="Test dialog" resizable="true" id="testdlg">+'<dialog title="Test dialog" resizable="true" id="testdlg">\r\n 
-  <multi_listbox extended_sel="true" minwidth="24" maxheight=8 id="dynamic_content_list">';+ <multi_listbox extended_sel="true" minwidth="24" maxheight=8 id="dynamic_content_list">';
  
 for(var nItem = 0; nItem < 100; ++nItem) for(var nItem = 0; nItem < 100; ++nItem)
-dialog_template += '    <Item text="Item ' + nItem + '" />';+  dialog_template += '\r\n'   <item text="Item ' + nItem + '"/>';
  
-dialog_template += '  </multi_listbox>+dialog_template += '\r\n' </multi_listbox>
-  <group uniform="true" align="right">+\r\n  <group uniform="true" align="right">
-    <button title="&amp;OK" returnval="ok" default="true"/>+\r\n    <button title="&amp;OK" returnval="ok" default="true"/>
-   <button title="&amp;Cancel" returnval="cancel"/>+\r\n   <button title="&amp;Cancel" returnval="cancel"/>
-  </group>+\r\n  </group>
-</dialog>';+\r\n</dialog>';
    
 Output().Clear(); Output().Clear();
Line 120: Line 120:
    
 // evaluate here returnCode (returnval of selected button) and decide if varStorage shall be evaluated // evaluate here returnCode (returnval of selected button) and decide if varStorage shall be evaluated
-if ( returnCode == "ok" ) {  +Output().writeln("Dialog template:"); 
-  Output().writeln("Dialog template:"); +Output().writeln(dialog_template); 
-  Output().writeln(dialog_template); + 
-  // convert VB array to JS array and output it +// convert VB array to JS array and output it 
-  Output().writeln("List selection: " + ax2js(varStorage.dynamic_content_list)); +Output().writeln("List selection: " + ax2js(varStorage.dynamic_content_list));
-}+
 </file> </file>