Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| scripting:dialogs:multi_listbox [2015/01/20 00:02] – [Example] admin | scripting:dialogs:multi_listbox [2018/01/10 20:41] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| List box control with ability to select several items. | List box control with ability to select several items. | ||
| + | {{ : | ||
| + | |||
| ===== Properties ===== | ===== Properties ===== | ||
| Line 7: | Line 9: | ||
| ^ Property | ^ Property | ||
| | **id** | | **id** | ||
| - | | **align** | + | | **align** |
| | **required** | | **required** | ||
| | **minwidth** | | **minwidth** | ||
| - | | **extended_sel** | + | | **extended_sel** |
| ===== Items ===== | ===== Items ===== | ||
| - | List Box is filled by // | + | List Box is filled by // |
| ==== Item ==== | ==== Item ==== | ||
| Line 25: | Line 27: | ||
| <file javascript multi-list-box.hejs> | <file javascript multi-list-box.hejs> | ||
| #include " | #include " | ||
| + | |||
| + | var varStorage = new Storage(); | ||
| // dynamically mark as selected first and third items | // dynamically mark as selected first and third items | ||
| // (function js2ax as ax2js defined in he_utils.js) | // (function js2ax as ax2js defined in he_utils.js) | ||
| - | var multi_listboxindex | + | // value passed as part of variable storage |
| + | varStorage.dynamic_list | ||
| + | |||
| + | // passing selection state using global script variable | ||
| + | // in this case using of Storage object is not needed | ||
| + | var global_dynamic_list = js2ax(new Array(1,3)); | ||
| var dialog_template = | var dialog_template = | ||
| ' | ' | ||
| - | < | + | < |
| - | <item text=" | + | <item text=" |
| - | <item text=" | + | <item text=" |
| - | <item text=" | + | <item text=" |
| - | <item text=" | + | <item text=" |
| - | <item text=" | + | <item text="Item 5"/> \ |
| - | <item text=" | + | <item text=" |
| - | <item text=" | + | <item text=" |
| - | <item text=" | + | </ |
| - | <item text=" | + | < |
| - | <item text=" | + | <item text=" |
| + | <item text=" | ||
| + | <item text=" | ||
| + | <item text=" | ||
| + | <item text=" | ||
| + | <item text=" | ||
| + | <item text=" | ||
| + | </ | ||
| + | < | ||
| + | <item text=" | ||
| + | <item text=" | ||
| + | <item text=" | ||
| + | <item text=" | ||
| + | <item text=" | ||
| + | <item text=" | ||
| + | <item text=" | ||
| </ | </ | ||
| - | <group uniform=" | + | <group uniform=" |
| - | <button title="& | + | <button title="& |
| - | <button title="& | + | <button title="& |
| - | | + | </ |
| </ | </ | ||
| + | |||
| // show dialog using dialog template and variables storage for passing initial data | // show dialog using dialog template and variables storage for passing initial data | ||
| var returnCode = dialog(dialog_template, | var returnCode = dialog(dialog_template, | ||
| - | // evaluate here returnCode | + | Output().Clear(); |
| // after closing of the dialog variable storage (varStorage) contains all states | // after closing of the dialog variable storage (varStorage) contains all states | ||
| - | // of the controls (which has variable id connected) | + | // of the controls (which has variable id connected) |
| - | + | ||
| - | Output().clear(); | + | |
| Output().writeln(" | Output().writeln(" | ||
| + | |||
| + | // evaluate here returnCode (returnval of selected button) and decide if varStorage shall be evaluated | ||
| + | if ( returnCode == " | ||
| + | // convert VB array to JS array and output it | ||
| + | Output().writeln(" | ||
| + | Output().writeln(" | ||
| + | Output().writeln(" | ||
| + | } | ||
| + | </ | ||
| - | // convert VB array to JS array and output it | + | ===== Dynamic content ===== |
| - | Output().writeln(" | + | Creating content dynamically is not straightforward, |
| - | </file> | + | < |
| + | #include " | ||
| + | |||
| + | var varStorage = new Storage(); | ||
| + | var dialog_template = | ||
| + | '< | ||
| + | < | ||
| + | for(var nItem = 0; nItem < 100; ++nItem) | ||
| + | dialog_template += ' | ||
| + | |||
| + | dialog_template += ' | ||
| + | \r\n <group uniform=" | ||
| + | \r\n <button title="& | ||
| + | \r\n < | ||
| + | \r\n </ | ||
| + | \r\n</ | ||
| + | |||
| + | Output().Clear(); | ||
| + | |||
| + | // show dialog using dialog template and variables storage for passing initial data | ||
| + | Output().writeln(" | ||
| + | |||
| + | // evaluate here returnCode (returnval of selected button) and decide if varStorage shall be evaluated | ||
| + | Output().writeln(" | ||
| + | Output().writeln(dialog_template); | ||
| + | |||
| + | // convert VB array to JS array and output it | ||
| + | Output().writeln(" | ||
| + | </ | ||