Having trouble with table field Renderer boolean depending on name

Hi,

I tried following this guide and applying it to my situation but I get stuck when trying to update the value. https://docs.skuid.com/v10.0.4/en/skuid/javascript/snippets/table-custom-field.html

I’ve running a custom field Renderer on the Quantity field and it shows the field correctly, but I can’t get it to update the field with a number instead of a true or false.

Where do I put the js function that updates the model? I know I need to use this code, but how do I format the function around the event of clicking the checkbox?

field.model.updateRow( field.row, field.id,  ); This is the code I currently have var field = arguments[0], value = arguments[1], $ = skuid.$; function updateField() { field.model.updateRow(field.row, field.id, 1); console.log('function working'); } switch (field.row.Name) { case 'GoPro rental (per day)': skuid.ui.fieldRenderers.BOOLEAN.edit( field, value ); break; case 'Private guide (per day)': skuid.ui.fieldRenderers.BOOLEAN.edit( field, value ); break; case 'Compass rental (per day)': skuid.ui.fieldRenderers.BOOLEAN.edit( field, value ); break; default: skuid.ui.fieldRenderers.PICKLIST.edit( field, value ); break; } 

Thank you for any help you can provide!

Sam,

I think you’ll have to modify the code a bit more than expected. Basically, to be able to edit the value of your row based on the checkbox, I think you have to create and add the checkbox to the DOM, so that you can take custom actions when it’s checked or unchecked. This is what I’ve been able to come up with:

var $ = skuid&#46;$, field = arguments[0], value = arguments[1], cellElem = field&#46;element; &#47;&#47; if the field is in read mode if ( field&#46;mode == 'read' ) { &#47;&#47; just use the standard Integer read-mode renderer &#47;&#47; you can customize this as well, if needed skuid&#46;ui&#46;fieldRenderers&#46;INTEGER&#46;read(field,value); } else if (field&#46;mode == 'edit') { &#47;&#47; this function runs whenever the checkbox is clicked function optionClickHandler ( event ) { &#47;&#47; get the new value from the click event, either true or false var newValue = event&#46;target&#46;checked; &#47;&#47;if true (checkbox is checked), update the Quantity field to 1 (or modify this to whatever the value should be) if (newValue) { field&#46;model&#46;updateRow( field&#46;row, field&#46;id, 1 ); } else { field&#46;model&#46;updateRow( field&#46;row, field&#46;id, 0 ); } } &#47;&#47; modify this to fit what you need &#47;&#47; I changed from switch case to if else so you didn't have to duplicate var name = field&#46;row&#46;Name; if (name === "GoPro rental (per day)" || name === "Private guide (per day)") { var v = false; if (value == 1) { v = true; } &#47;&#47; create a checkbox DOM element, making it checked or not based on the value, and attaching the click handler function to it var checkbox = $( '' )&#46;attr('checked', v)&#46;click(optionClickHandler); &#47;&#47; add the checkbox element to the original DOM element so that it shows up on the page checkbox&#46;appendTo( cellElem ); } else { skuid&#46;ui&#46;fieldRenderers&#46;PICKLIST&#46;edit( field, value ); } }<br /><br />

You might need to do some tweaks based on what you specifically want to do, but I think this is headed in the right direction

Thanks!
Amy