durtto / cherryonext

Automatically exported from code.google.com/p/cherryonext
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Value incorrect for editor grid #13

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.  Using numeric IDs for values will cause the problem when the field is a
combobox.
2.  If the value we are looking for is 9 and there is a 91 before in the
store, it will return the index for record 91, bringing up the wrong value.
3.

What is the expected output? What do you see instead?
I should be seeing the item selected in the combobox, but instead I see an
item that was listed below with the same value prefix.

Please use labels and text to provide additional information.
The problem is in getValue. This will find the first record with a prefix
of val[i].  

    var j=this.store.find('value',val[i],0,false,this.caseSensitive);

My solution.  I'm not sure this is how it should be fixed as it means
having to set an id.

    var record=this.store.getById(val[i]);

The following is my complete change to getValue

 getValue: function() {
    var
val=Ext.ux.netbox.core.AvailableValuesEditor.superclass.getValue.call(this);
    if(Ext.type(val)=='string'){
      val=val.split(',');
    }
    var toReturn=[];
    for(var i=0; i<val.length;i++){
//    var j=this.store.find('value',val[i],0,false,this.caseSensitive);

      var record=this.store.getById(val[i]);
//    if(j<0)
//        continue;
//     var record=this.store.getAt(j);
      if(record == undefined)
          continue;
      toReturn.push({label: record.get('label'), value: val[i]});
    }

    if((val.length>0 && val[0]!=="") && toReturn.length==0)
      return(this.originalValue);
    else
      return toReturn;
  }

Original issue reported on code.google.com by billeat...@hotmail.com on 27 Dec 2008 at 2:56

GoogleCodeExporter commented 8 years ago
I fixed this one by changing the line:
var j=this.store.find('value',val[i],0,false,this.caseSensitive);
into:
var j=this.store.findExact(this.valueField,val[i]);

This doesn't need setting an id

Original comment by mihai.se...@gmail.com on 20 Aug 2010 at 9:12