Task Subject Field Accepting Custom Field Renderer

  • 1
  • Problem
  • Updated 4 years ago
Uncaught TypeError: Cannot read property '0' of null           skuid__SkuidJS:26


Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Andrew Duensing

Andrew Duensing, Employee

  • 740 Points 500 badge 2x thumb
Hey Pat, since this looks like it's pretty specific, do you think you could open the dev tools, click on the console, and then give us a screenshot of the errors that come up when you refresh the page with the custom field rendered applied to the field that is breaking it.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb




Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,470 Points 10k badge 2x thumb
Subject is a weird field.  It has a display type of COMBOBOX which skuid does not have a renderer for.

Try adding this line above the renderer code.

var displayTypeToUse;
if (field.metadata.displaytype === 'COMBOBOX') {
    displayTypeToUse = 'TEXT';
} else {
    displayTypeToUse = field.metadata.displaytype;
}


Then use displayTypeToUse instead of field.metadata.displaytype.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
Still no dice.
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,470 Points 10k badge 2x thumb
Can you paste in the exact code you're trying?  I'll try it on the same field.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
var $ = skuid.$,
    field = arguments[0],
    value = arguments[1];

if (field.mode === 'read') {

    field.element.append(skuid.$('<div>').addClass('nx-fieldtext').text(field.model.getFieldValue(field.row,skuid.utils.getFieldReference(field.id,field.metadata))));

} else {

    skuid.ui.fieldRenderers.TEXT.edit(field,value);

}
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,470 Points 10k badge 2x thumb
The skuid.utils.getFieldReference() will only work on REFERENCE type fields.  For non reference fields, you can just use value to put into the text.  Like this...


var $ = skuid.$,    field = arguments[0],
    value = arguments[1];
if (field.mode === 'read') {
    field.element.append(skuid.$('<div>').addClass('nx-fieldtext').text(value));
} else {
    skuid.ui.fieldRenderers.TEXT.edit(field,value);
}
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
Yup. That was it.