jQWidgets Forums

jQuery UI Widgets Forums Grid Get Column Index from Createeditor

This topic contains 1 reply, has 1 voice, and was last updated by  Benji6996 10 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Get Column Index from Createeditor #55307

    Benji6996
    Participant

    I have written a script that applies the createeditor callback dynamically. However, I need to be able to determine which column the editor is being created on so I can apply custom settings to each of the cells that the editor is created on.

    For example, my script will apply a jqxNumberInput to any columns that have {'columntype':'numberinput'} set, but each column will have different settings for this such as decimal places etc. Resultantly, I need to know which column the cell is in so I can apply the relevant settings.

    This is my code so far:

    // Loop through each of the columns
    for(var x in data.columns){
    	// If the column is a number input then apply the number input editor
    	if(data.columns[x].columntype=='numberinput'){
    		// Append the relevant column object with the createeditor callback
    		data.columns[x] = $.extend({
    			createeditor: function(row,cellvalue,editor){
    				editor.jqxNumberInput({
    					decimal: cellvalue,
    					inputMode: 'simple',
    					max: 99999999999999999999,
    					min: -99999999999999999999,
    					decimalDigits: data.columns[x].decimal_places, // THIS IS WHAT DOES NOT WORK
    					decimalSeparator: data.localization.decimalseparator,
    					digits: 20
    				});
    			}
    		},data.columns[x]);
    	}
    }
    Get Column Index from Createeditor #55308

    Benji6996
    Participant

    Thanks to another answer I have found within this forum, I was able to fix this issue like so:

    $.each(data.columns,function(index,value){
    	// If the column is a number input then apply the number input editor
    	if(data.columns[index].columntype=='numberinput'){
    		// Append the relevant column object with the createeditor callback
    		data.columns[index] = $.extend({
    			createeditor: function(row,cellvalue,editor){
    				editor.jqxNumberInput({
    					decimal: cellvalue,
    					inputMode: 'simple',
    					max: 99999999999999999999,
    					min: -99999999999999999999,
    					decimalDigits: data.columns[index].decimal_places,
    					decimalSeparator: data.localization.decimalseparator,
    					digits: 20
    				});
    			}
    		},data.columns[index]);
    	}
    });
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.