Skip to main content

I’m trying to use a custom field renderer in my table to render a field based on the value of another field in the row. This seems to not work.


I have on the field “Field Rendererer: Custom (run a Snippet)” and I’ve entered my snippet as follows:


“In-Line (Snippet)”


var params = arguments 0],
$ = skuid.$;
var field = arguments 0];
var cellElem = field.element;
var row = field.row;
var value = arguments 1];

var m = skuid.model.getModel('DynamicReportFinancialInclude\_\_Conditions');

var operator = row.Operator\_\_c;
var operator2 = rowr'Operator\_\_c'];
var operator3 = m.getFieldValue(row,'Operator\_\_c',true);

console.log('SKUID RECORD OPERATOR: '+operator+','+operator2+','+operator3);

console.log('ROW:');
console.log(row);

if(operator !== undefined && operator !== null){
skuid.ui.getFieldRenderer(field.metadata.displaytype).edit( field, value );
}

Here’s the console output:



As you can see, the first output (operator,operator2,operator3) shows “undefined,undefined,null” for the 3 different ways I try to pull it. But then when I output the row itself, sure enough under the row I have Operator__c: “=”. What am I doing wrong here in trying to get the reference to the value of Operator__c from the row passed to the javascript snippet via context?


Thanks!

I figured it out, but also have another question…


I was creating rows via this sort of javascript logic:


m.updateRow(m.createRow({doAppend: true}),{
Operator__c: '='
});
So what this did was first create the row then immediately update it. Because of this, the field renderer on the table saw that the operator as undefined at first (when it decided to run its render logic) and then only later on update did this change. The display logic for the renderer didn't re-run after update, so it continued to operate as if the Operator was undefined

I've updated the create row logic as follows:

m.createRow({doAppend:true, additionalConditions:s
{field: 'Operator__c', value: '='}
]}
);
So now it's running the render logic on the newly created row that has the operator field already specified, and works.


Additonal Question:

How can I get the custom field renderer to re-render dynamically? Let's say that I create the row and the operator isn't "=" and then the user manually specifies the operator to be "=", will the field renderer update the display automatically, or can I somehow tell it to update?

Hi Mark, you could add a UI-only field of type “Formula” that simply uses the {{Operator__c}} field. To trigger updating the renderer, run the following in a snippet:
skuid.$M(“modelName”).evaluateFormulaFields();

By mirroring the operator in the UI-only field and using it in the Table (instead of the original Operator field), and adding the snippet, that ought to trigger the UI-only field to be re-rendered.

We hope that this is what you are looking for.


Thank you Luzie I’ll have to try that out.


Reply