Is there any way to pass parameters to the column's "formatter" option function from MVC?
I need to use regional settings, so I can't use the built-in format option because it uses en-US settings only. So, I'm using the formatter option to format my fields with regional settings, but I'd like to be able to specify the number of decimal places allowed in my "toRegionalDecimalString" function, for example.
Perfect, thanks a lot. I didn't think this could be done!
Here is the working code:
if (column.type == 'image') { option.dataType = "object"; option.template = "<img width='16' height='16' src=${" + column.propertyName + "}></img>"; option.formatter = function (value, record) { return getImageSource(value, "myCustomParam", "myOtherParam"); }; }
Regards, Maria
Hello Maria,
Unfortunately, the grid doesn't pass that. If you have a single formatter function for multiple columns you could assign (as their formatters) anonymous functions that call the actual formatter one with the additional argument of that column's key.
Best regards,
Stamen Stoychev
Thanks for your reply: I'm currently using Ignite 16.2 and I'm seeing now that also this version ships the additional 'record' parameter.But I also need to know on which column the function is being invoked: is there a workaround to obtain that information?
Thanks again.
This might be the case if you are using an older version but in recent ones the formatter receives both the value and the whole record (as shown in the code snippet here). The template is also executed against the whole record so you can reference other properties from inside.
Hi Borislav,again on this topic: unfortunately column formatters only have one parameter, which is the current value of the cell. Is it possible, at least, to get informations about the current row and column? I was thinking at something similar to knockout's event parameters, "data" and "event".
I would like to render a numeric column as an image column, so I customized column options with a template and a formatter, as suggested here.I need to obtain an image source not only depending on the current value, but also depending on something like a custom matrix, which is different for each column: value1>imageA, value2>imageB, etc.
Could you please help me implementing such a feature on my igGrid?Thank you, Maria