01-12-2021, 04:06 PM
I am trying to see if I can get the LookAheadTextInputWdg to work as a look ahead on the name column of a simple look up table then if the user does not select someting, insert the text they typed in as a new entry in the lookup table. I somewhat have this working as I noticed that using spt.api.get_input_values returns the list of options/results as name/value pairs. Its seems that what the user types ends up being the last two items in the array. If the second last item is empty, it indicates that there wasnt a result and I should create a new entry in the LUT.
I guess the question is if there is a simpler\built-in way to do this? I have an example below of my element and the test code I put together to see if it could work.
And the save button behavior
I guess the question is if there is a simpler\built-in way to do this? I have an example below of my element and the test code I put together to see if it could work.
Code:
<div class="test_top" style="width:400px; height:400px">
<h2>Look Ahead Test</h2>
<button class="save">SAVE</button>
<div class="form-item">
<div class="form-input">
<element name="city">
<display class="tactic.ui.input.LookAheadTextInputWdg">
<search_type>test/city</search_type>
<column>name</column>
<value_column>name</value_column>
<hint_text>Type the city</hint_text>
<validate>true</validate>
</display>
</element>
</div>
</div>
</div>
And the save button behavior
Code:
var server = TacticServerStub.get();
var test_el = bvr.src_el.getParent("test_top");
var input_values = spt.api.get_input_values(test_el);
if (input_values.city[input_values.city.length-2]) {
alert("in list");
}
else {
server.insert("test/city", {'name': input_values.city[input_values.city.length-2]});
alert("not in list - added");
}
console.log(input_values);