Feature #1242

Mode Suggest paramétrable

Added by Stéphane Bourmaud about 1 year ago. Updated about 1 year ago.

Status:Nouveau Start date:04/27/2012
Priority:Minor Due date:
Assignee:- % Done:

0%

Category:-
Target version:-

Description

Bonjour,
j'ai modifié le code de rialto.js pour permettre d'avoir un parametre supplémentaire pour le mode suggest.
le parametre est suggestMethod qui peut prendre la valeur start ou contain
dans le premier cas le suggest ne renvoit que la liste des occurences commençant par la chaine saisie
dans le second cas il renvoit la liste des occurences qui contienne la chaine saisie.

modifications :

rialto.widget.Combo = function (tabData, name, top, left, width, parent, objPar) {
    if (!objPar) {
        var objPar = {};
    }
    objPar.name = name;
    objPar.type = "combo";
    objPar.left = left;
    objPar.top = top;
    objPar.width = width;
    this.base = rialto.widget.AbstractComponent;
    this.base(objPar);
    this.enable = true;
    this.writable = true;
    this.suggest = true;
    this.suggestMethod ="contain" ;
    this.asynchSuggest = true;
    this.isRequired = false;
    this.timeForSuggest = 1500;
    this.urlForSuggest = null;
    this.nbCharForSuggest = 3;
    this.special = "";
    this.open = false;
    this.heightItem = 23;
    this.wvalue = "";
    this.alt = null;
    this.itemTextClassName = "";
    if (rialto.lang.isBoolean(objPar.suggest)) {
        this.suggest = objPar.suggest;
    }
    if (rialto.lang.isString(objPar.suggestMethod)) {
        this.suggestMethod = objPar.suggestMethod;
    }

rialto.widget.Combo.prototype.prepareList = function () {
    if (this.suggest) {
        this.currentListItem = new Array;
        strSaisi = this.getValue().toLowerCase();

        for (i = 0; i < this.initListItem.length; i++) {
            if(this.suggestMethod.valueOf() == 'contain') {
            if (this.initListItem[i].text.toLowerCase().indexOf(strSaisi) != -1) {
                this.currentListItem.push(this.initListItem[i]);
            }
          } else if(this.suggestMethod.valueOf() == 'start') {
            if (this.initListItem[i].text.toLowerCase().indexOf(strSaisi) == 0) {
                this.currentListItem.push(this.initListItem[i]);
            }
          }
           else {
            if (this.initListItem[i].text.toLowerCase().indexOf(strSaisi) == 0) {
                this.currentListItem.push(this.initListItem[i]);
            }
          }

        }
    }
};

History

Updated by Frédéric ESNAULT about 1 year ago

Bonjour,

Merci beaucoup pour cette contribution qui sera très probablement intégrée à la prochaine version.

Also available in: Atom PDF