1
votes

I would like to use typeAhead functionality in a inputBox. Values should get only the first categorized column( Column[0]); Because I have so many document belong to the same customer. I only need customer names as unique. Please find what i tried so far below. in this view only the first column is categorized. Others are not. I think i miss something :(

<xp:inputText id="inpCustomer" value="#{document1.CustomerName}">
<xp:typeAhead mode="partial" minChars="2" ignoreCase="true" var="lupkey" valueMarkup="true" id="typeAhead1">
                                <xp:this.valueList><![CDATA[#{javascript:try
    {
        var procedureName = "fonck1";
        var searchOutput:Array = [];
        var v:NotesView = database.getView("(ctgViewName)");
        var nav:NotesViewNavigator = v.createViewNavFromCategory(lupkey);
        var viewEnt:NotesViewEntry = nav.getFirstDocument();
        var tmp:NotesViewEntry;

        while (viewEnt !== null)
        {  
            searchOutput.push(entry.getColumnValues()[0]);
            tmp = viewEnt;
            viewEnt = nav.getNextCategory();
            tmp.recycle();
        }

        var result ="<ul><li><span class='informal'></span></li>";
        var limit = Math.min(hits,200);

        for (j=0; j<limit; j++) 
        {
            var name = searchOutput[j].toString();
            var start = name.indexOfIgnoreCase(lupkey)
            var stop = start + lupkey.length;
            name = name.insert("</b>",stop).insert("<b>",start);
            result += "<li>" + name + "</li>"; 
        }
        result += "</ul>";
        return result;
    }
    catch(e)
    {
        print(e.toString());
        throw(e);
    }}]]></xp:this.valueList>
                            </xp:typeAhead>
                            <xp:this.attrs>
                                <xp:attr name="placeholder" value="Please enter customer name..." />
                            </xp:this.attrs>

                    </xp:inputText>
1

1 Answers

1
votes

Reduce searchOutput array to just the names which start with the entered characters.

Start view navigator at first occurence of such a name:

var v:NotesView = database.getView("(ctgViewName)");
var viewEnt:NotesViewEntry =  v.getEntryByKey(lupkey, false)
var nav:NotesViewNavigator = v.createViewNavFrom(viewEnt);

Stop putting names into searchOutput array when name starts different than lupkey.
Replace your first line in while statement with:

var name:String = entry.getColumnValues()[0]; 
if (!name.startsWith(lupkey)) {
    break;
}     
searchOutput.push(name);