jQWidgets Forums

jQuery UI Widgets Forums Grid Prevent Editor Blur on 'setcellvalue'

This topic contains 4 replies, has 2 voices, and was last updated by  Benji6996 10 years, 9 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author

  • Benji6996
    Participant

    Would it be possible to prevent the blur event on the ‘editor’ when the ‘setcellvalue’ method is called in Internet Explorer?

    I have a script that calculates ‘column B’ based on the value entered in ‘column A’. The problem is, as soon as I enter a number into the grid (jqxNumberInput), it loses focus of the editor in the grid! This only appears to happen in Internet Explorer…

    Here is my code:

    var createeditor = function(row,cellvalue,editor){		  
    	editor.jqxNumberInput({
    		decimal: cellvalue,
    		inputMode: 'simple',
    		max: 99999999999999999999,
    		min: -99999999999999999999,
    		decimalDigits: user_settings.dp_Quantity,
    		decimalSeparator: user_settings.Decimal_Pointer,
    		digits: 20
    	});
    	// Calculate the new balance on change and keydown
    	editor.on('change keydown',function(){
    		var editor = $(this);
    		// Get the selected row index
    		var row = $('#pl_product_grid').jqxGrid('getselectedrowindex');
    		// Get the cells from the grid
    		var shipped = $('#pl_product_grid').jqxGrid('getcellvalue',row,'shipped');
    		var other_packs = $('#pl_product_grid').jqxGrid('getcellvalue',row,'other_packs');
    		// Only get the value once the change has been registered
    		setTimeout(function(){
    			var balance = shipped-(other_packs+editor.val());
    			// Set the new balance
    			$("#pl_product_grid").jqxGrid('setcellvalue',row,'balance',balance);
    		},100);
    	});
    };

    Peter Stoev
    Keymaster

    Hi Benji6996,

    The problem here is that “setcellvalue” shouldn’t be called within createeditor and while an editor is active at all. May be you should use “cellendedit” event handler for that purpose.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    Benji6996
    Participant

    Thanks for your prompt reply Peter.

    I’m not surprised that is the case. However, is there a better way I can have a column that is editable and whilst it is edited, the another columns value is calculated? Or is it only possible to do once the cell edit has ended?


    Peter Stoev
    Keymaster

    Hi Benji6996,

    The possible solution would be to use “updaterow” or “setcellvalue” in the “cellendedit” event handler. Otherwise, you may try this approach: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/computedcolumn.htm?arctic which shows how to create a computed and non-editable column.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    Benji6996
    Participant

    The computed column example looks like the perfect solution! Thanks Peter

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.