1. #1
    Sencha User catacaustic's Avatar
    Join Date
    Jul 2007
    Location
    "A Land Down Under"
    Posts
    618
    Vote Rating
    1
    catacaustic is on a distinguished road

      0  

    Default Grid renderer showing incorrect values

    Grid renderer showing incorrect values


    I've got a problem with a pretty complex grid renderer in an editable grid.

    I'm using the grid to enter new items as well as edit existing items. To add new items I add a blank record into the data store so that the user can enter their values. That works fine, and I've got the adding and editing parts all working as I want them.

    The problem is that when I add a empty record into the data store. The editors that I'm having issues with are ComboBoxes, so to get the value to display in the grid when editing is finished I get the value from the ComboBox. Took me a long time (and a lot of help on here) to figure out how to do that. That works when I've got a single empty row in the grid, and nothing else. As soon as I add an empty record into the data store when it contains some other records and this new empty record displays on the grid, the columns that have ComboBox's for editors take on the value that was last set for that ComboBox, seeing as how all of the fields in the column are all bound to the same ComboBox editor. So, when there is no values in the field, it still displays the value that was set in the last row even though when you edit this field it is blank.

    As you can imagine this is pretty confusing. People will see values in the grid when there really aren't any there, and wonder why it's not working as they expect, or why there's "default" values that they don't want.

    So far I've tried these ideas without any luck:
    • Checking the value in the record that's associated with that row for "no value". This returns that there is no value, but I can't set the display to nothing for that because when a user chooses a value the record doesn't update with that value, so nothing is shown even when the user has chosen something correctly.
    • Resetting the editor. This doesn't work because I can get the editor from the grids column model, but it is returned as only an object, so the editor doesn't have the reset () function, so it can't be reset when I need it to.

    Is there something else that I can do that will work with this? It's pretty complex, so I know how hard it is to find a solution to this. The renderer as it stands now is...
    Code:
    renderGridSelect: function (val, p, record, rowIndex, colIndex, ds) {
    	var grid = App.Panel.getActiveGrid ();
    	
    	var value = "";
    	var valName = "";
    
    	if (grid !== undefined) {
    		value = grid.getColumnModel ().getCellEditor (colIndex, rowIndex).getValue ();
    		
    		if (value == undefined || value == "") {
    			var ary = record.getData ();
    			
    			var index = 0;
    			
    			for (var i in ary) {
    				if (index == colIndex) {
    					value = ary [i];
    					valName = ary ["name" + i];
    				}
    				
    				index++;
    			}
    		}
    		
    		var cm = grid.getColumnModel ();
    		var ce = cm.getCellEditor (colIndex, rowIndex);
    
    		if (ce.field.store.getById (value) !== undefined) {
    			value = ce.field.store.getById (value).get ("name");
    		} // if ()
    		else if (valName != "") {
    			value = valName;
    		}
    	}
    	
    	return value;
    }
    I've also attached a basic shot of what the problem looks like.

    Is there any way around this??
    Attached Images
    'Once again, fortune vomits on my eiderdown'
    - Edmund Blackadder

  2. #2
    Sencha User catacaustic's Avatar
    Join Date
    Jul 2007
    Location
    "A Land Down Under"
    Posts
    618
    Vote Rating
    1
    catacaustic is on a distinguished road

      0  

    Default


    Is there no one else that has had a problem similar to this?

    As anyone else out there even used an editor grid to enter new data records even remotely close to this, and how is it supposed to happen?

    So far all I can see is this looks like a pretty big problem as the framework isn't showing things the way that it really should be. Right now I'm desperately clutching for any ideas that I can get on how I can get around this problem.
    'Once again, fortune vomits on my eiderdown'
    - Edmund Blackadder