jQuery UI Widgets › Forums › Grid › Get Column Index from Createeditor
Tagged: column, createeditor, dynamic, getcolumnindex, jqxgrid
This topic contains 1 reply, has 1 voice, and was last updated by Benji6996 11 years, 11 months ago.
-
Author
-
I have written a script that applies the
createeditorcallback 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]); } }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]); } }); -
AuthorPosts
You must be logged in to reply to this topic.