Is there way to update listbox element that filled with JS array elements. If I push more elements to the array, how I can re-render it in ScriptUI? Is there way to do this.
I know there is way just to add elements to listbox like in Peter Kahrel's PDF. But this isn't so dynamic:
var w = new Window ("dialog"); var myList = w.add ("listbox", undefined, ["one", "two", "three"]); var b = w.add ("button", undefined, "Add"); b.onClick = function () {myList.add ("item", "zero", 0)} w.show ();
How about if I wan't to update listbox when I have changed my arrays, like below:
// Create example array var testArr = ['item1', 'item2'] $.writeln(testArr.length); startGUI(); function startGUI() { // Window var win = new Window( "palette", script_name, undefined, { resizeable:true } ); win.orientation = "column"; win.alignChildren = ["fill", "fill"]; // Listbox var myListbox = win.add ("listbox", undefined, testArr, { numberOfColumns: 1, showHeaders: true, columnTitles: ['Name'] }); // Add Item To Array var addItem = win.add("button", undefined, "Add Item"); addItem.onClick = function() { testArr.push ('item3'); $.writeln(testArr.length); } // Quit BTN win.quitBtn = win.add("button", undefined, "Close"); win.quitBtn.onClick = function() { win.close(); } win.show(); }
Maybe there is some update funtion on ScriptUI. I tried to search solution without success. Any help?