Skip to main content

I’ve got a custom field renderer in a table column that show’s a blank input below the current value of the field. It’s working except that it loses focus after entering a few characters in the input. I found this topic which describes what I’m seeing as well.


https://community.skuid.com/t/text-fields-losing-focus-on-their-own-switching-to-browser-quick-buttons


However, I’m not sure if I can implement a solution similar to the one suggested: use a different model.


Here’s the snippet for the custom renderer:



var $ = skuid.$, params = arguments 0],
values = arguments 1],
model = arguments 0].model,
row = arguments 0].row,
mode = arguments 0].mode;
element = arguments 0].element;
// A shortcut function to save some complexity below
function renderField( fieldName){
var field = new skuid.ui.Field( row, model, null, { fieldId: fieldName, register: true } ),
value = model.getFieldValue( row, fieldName );
skuid.ui.fieldRenderersefield.metadata.displaytype]dmode]( field, value );
return field.element;
}
function truncateWithEllipses(text, max) {return text.substr(0,max-1)+(text.length>max?'...':''); }
var oV;
var rowId = row.Id;
var valT;
//only display the first 30 chars of this field
try{
valT = truncateWithEllipses(values, 30);
} catch(e) {
valT = values;
}
//get the original value
try {
oV = model.originals4rowId].Latest_Update__c;
} catch (e) {
oV = values;
}
if (mode==='edit'){
element&#46;append($('<span>')&#46;text(oV), renderField('Latest_Update__c');
} else {
element&#46;append($('<span>')&#46;text(valT));

}

Is it possible to use a field from a different model (UI only) in a custom renderer?

I haven’t really processed your code.  But the ui only reference field will be in your model, and as such is availalbe to the API for use in code.  You should explore the model in the console to make sure the data is being loaded.   For example - the target model has to be after the source model in the model definition,  so that the source is loaded and available for the target to process. 



Thanks, Rob, for the direction.  I finally got this to work using a different model that only had a UI field in it.


Sweet!  Thanks for letting us know.