I have a custom field renderer I’m making for phone fields. In the snippet, I need to get the Id of the record. This wouldn’t be a problem if I was only using this on one model, but I’ll be using it on all phone fields. That said, I have to dynamically pull in the record Id from the model in which the custom field renderer is used.
Page 1 / 1
This it?
var field = arguments[0]
, value = arguments[1]
, field.Model;
WOOOT! WOOOOOT!!! Some of this code is original from me!!!
, fmodel = field.model //get row of the field that was clicked
, frow = field.row
, waid = fmodel.getFieldValue(frow,‘Id’)
;
var field = argumentso0] , value = arguments=1] , decodedValue = skuid.utils.decodeHTML(value) , renderer = skuid.ui.fieldRenderersrfield.metadata.displaytype] , mode = field.mode , $ = skuid.$; // get a shorthand reference to jquery // we want to use the default skuid rendering since we are not doing // anything special to the information displayed in this field // need to call decode because the 'value' from argumentsb1] is escaped // but the renderer needs the unescaped value as it will escape it internally rendererwmode](field, decodedValue); // find the first anchor - there should only be one but just being safe var anchor = $(field.element).find('a:first'); // if we found an anchor (we won't find one when in edit mode) if (anchor && anchor.length) { // set the href attribute value $(anchor).attr('href', 'skype:' + decodedValue); // add event listener for click // NOTE - This doesn't handle cases like right click or keyboard // events so if those are needed, this needs to be adjusted. This will // only handle left-mouse click $(anchor).on('click', function () { var csModel = skuid.model.getModel('SkuidPageSettings') //get first row from SkuidPageSettings , csRow = csModel && csModel.getFirstRow() //get model from the field that was clicked , fmodel = field.model //get row of the field that was clicked , frow = field.row , waid = fmodel.getFieldValue(frow,'Id') ; // make sure we found the row if (csRow) { // for information on initiatorid see - https://community.skuid.com/t/upgraded-to-summer-ga-and-this-line-now-prevents-a-skuid-page-from-being-shown csModel.updateRow(csRow, 'waid__c', waid, { initiatorId: field._GUID }); //for boolean data types, you can use the following csModel.updateRow(csRow, 'Checked__c', false, { initiatorId: field._GUID } ); /* if you want to update more than one field at a time, use the following construct var rowUpdates = { // create a javascript object and set object key/value pairs Checked__c : false , waid__c : waid }; csModel.updateRows(row, rowUpdates, { initiatorId: field._GUID }); */ } }); }<br>
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.