• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

[HELPED] Grid with Cell Editing - problem with Summary Feature

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [HELPED] Grid with Cell Editing - problem with Summary Feature

    I have an application with an Grid using Cell Editing that was all working fine. I tried adding a Summary feature to it and have run into a problem. The summary is working fine if I change any cells except one. That cell has the following renderer function:

    Code:
                renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
        			value = value.toUpperCase();
    				record.set('KDIDES', value);
    				return value;
    			},
    The line record.set.... causes my grid to disppear unless only digits are entered, the column headings remain but the rest disappears. Only one column uses the summary function and it is not this one. The error I get in the console is

    Uncaught TypeError: Cannot call method 'removeChild' of null at ext-all.js:18


    I was using the record.set to save the upper case value of whatever the user typed. Maybe I should do something different???

    Thanks,

    Scott

    P.S. Below is code that I have stripped out of my applicaiton that I believe someone can run to see the issue. When it displays click the 'SAVE' button to add lines to the grid then put any characters in the description field and Tab out of it.

    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="Copyright" content="Davis Transport Inc, All Rights Reserved">
    <title>Accounts Payable Transaction Entry</title>
    <link rel="stylesheet" type="text/css" href="/extjs4/resources/css/ext-all.css" />
    <link rel="stylesheet" type="text/css" href="/vvresources/valence.css" />
    <script type="text/javascript" src="/extjs4/ext-all.js"></script>
    <script type="text/javascript" src="/vvresources/valence-extjs4.js"></script>
    <script type="text/javascript">
    
    var CellToUpdate;
    
    Ext.onReady(function() {
    	
        // turn on quicktips functionality
        Ext.QuickTips.init();
    	
    
        Ext.define('detail', {
    		extend: 'Ext.data.Model',
    		fields: ['KDIDES', 'KDAMT']
    	});
    	
    	var detailStore = Ext.create('Ext.data.Store',{
    		model : 'detail'
    	});
    
        //-----------------------------------------------------------------------------------------------
        // function to begin adding a record
    	var addRec = function() {
    
        	myViewport.layout.setActiveItem(0);
    		mode = 'add';
            detailStore.removeAll();
        	detailStore.add({'KDAMT':0
    		}, {'KDAMT':0
        	}, {'KDAMT':0
        	}, {'KDAMT':0
        	}, {'KDAMT':0
        	}, {'KDAMT':0
        	}, {'KDAMT':0
        	}, {'KDAMT':0
        	}, {'KDAMT':0
        	}, {'KDAMT':0
    		});
    		formEdit.down('#VENDOR').enable();
    		formEdit.getForm().reset();
    		formEdit.down('#VENDOR').focus();
            myViewport.doLayout();
    
    		};
    
         // form edit panel
        var formEdit = Ext.create('Ext.form.Panel', {
            frame: true,
            region: 'north',
        	header: false,
        	border: false,
        	labelAlign: 'right',
        	labelWidth: 105,
        	width: 400,
        	waitMsgTarget: true,
            tbar: [{
    			text: 'Save',
    			tooltip: 'Save',
    			iconCls: 'save',
    			handler: addRec
    		}],
        	items: [{
        		xtype: 'fieldset',
    			iconCls: 'application_view_detail',
    			title: 'Invoice Detail',
    			width: 500,
                defaults: {
                    labelAlign: 'left',
                    labelPosition: 'left',
                    labelWidth: 100,
                    selectOnFocus: true,
                    layout: {
                        type: 'hbox',
                        defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
                    }
                },
        		items: [{
        			xtype: 'fieldcontainer',
    				items: [{
        			    xtype: 'textfield',
        			    id: 'INVOICE',
                        name: 'INVOICE',
        			    fieldLabel: 'Invoice Number',
        			    width: 200,
                        maxLength: 8,
                        enforceMaxLength: true,
                        allowBlank: false
    				}]
         		}]
        	}]
        });
        
        ///////////////////////////////////////////////////////////////////////////////////////////
        var DetailGrid = Ext.create('Ext.grid.GridPanel', {
    		region: 'center',
    		store: detailStore,
    		defaults: {
    			width: 100
    		},
    		sortableColumns: false,
    		enableColumnHide: false,
    		enableColumnMove: false,
    		selType: 'cellmodel',
            features: [{
                ftype: 'summary'
            }],
    		plugins: [
    		Ext.create('Ext.grid.plugin.CellEditing', {
    			clicksToEdit: 1
    		})],
    
    		columns: [{
    			header: "<b>Description</b>",
    			width: 250,
    			dataIndex: 'KDIDES',
                renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
        			value = value.toUpperCase();
    				record.set('KDIDES', value);
    				return value;
    			},
    			editor: {
    				xtype: 'textfield',
    				maxLength: 20,
    				enforceMaxLength: true,
    				allowBlank: false,
                    selectOnFocus: true
    			}
    		}, {
    			header: "<b>Amount</b>",
    			dataIndex: 'KDAMT',
    			align: 'right',
    			renderer: 'usMoney',
                summaryType: 'sum',
    			editor: {
    				xtype: 'numberfield',
    				allowBlank: false,
    				hideTrigger: true,
    				minValue: -99999999.99,
    				maxValue: 99999999.99,
    				selectOnFocus: true
    			}
    		}]
    	});
    
        // viewport
    	new Ext.Viewport({
    		id: 'viewport',
    		layout: 'card',
    		activeItem: 0,
    		items: [
               {
        		title:'Invoice Details',
    			width:200,
    			//region:'east',
    			split:true,
    			layout:{
                    type: 'border'
    			},
    			items:[DetailGrid, formEdit]}]           
    	});
        
        var myViewport = Ext.getCmp('viewport');
        
    });
    </script>
    </head>
    <body>
    </body>
    </html>
    Last edited by Scott; 10-04-2013, 02:45 PM. Reason: added error message

  • #2
    If you use the summary feature, and have the same renderer, without the line of record.set(), does it work, or do you get the same error?

    Comment


    • #3
      If I take out the record.set() it works fine. I was doing the record.set() to retain the upper case or else if they go back into the field to edit then it will show the lower case value. If I have to I can leave out the record.set() and then do the upper case when updating the data base.

      Comment


      • #4
        you could try adding a record.commit() afterwards, but I can't imagine why the error is being caused.

        Also, with the cellediting plugin, you have some events you can hook onto that may be a good time to modify the record as well:

        beforeedit
        canceledit
        edit
        validateedit

        For more info about the listeners, reference the API:
        http://docs.sencha.com/extjs/4.1.3/#...ent-beforeedit

        Comment


        • #5
          The record.commit() inside the renderer makes the error happen before the grid can even be displayed!

          It seems to me that the summary feature is trying to do math on the value in this field when it is changed even though I haven't specified a summary on this field. I say that because if I just put digits in the field then it works ok, but any letter and I get the error. Almost like it is trying to use the characters to perform math and getting an error because of it. I even tried specifying a summaryType function on this field that just returns a string to see if I could stop it but that didn't affect the error.

          I will look at the events you mention to see if I can do the upper casing there instead and if that will allow me to avoid the error.

          Thanks

          Comment


          • #6
            Just an update in case anyone else tries to do the same thing. Using a listener on the edit event does just want I wanted.

            Code:
                DetailGrid.on('edit', function(editor, e) {
            		if (e.field == 'KDIDES') {
            			e.record.data[e.field] = e.value.toUpperCase();
            		}
            	});

            Comment

            Working...
            X