Script component, data will not bind (Wont save)

Posted by ByronB on 05-Jan-2015 10:37

Hi guys

I have a script component that replicates a multi select picklist so that we can rowspan to make things fit better on the form:

div id="divElemCT"></div>

var divElemCT = "<td class='rbs_rightLabel3' id='rbi_L_contactType'>Contact Type</td><td class='rbs_leftDataCol3' id='rbi_F_contactType' rowspan='3'><select name='contactType' tabindex='30' multiple='true' size='5'><option value='11553'>Commercial Contact</option><option value='11554'>Financial/Accounts</option><option value='11555'>Sales</option><option value='11556'>Marketing</option><option value='11557'>Technical/IT</option><option value='11558'>Operations</option><option value='11559'>Director/Owner</option></select></td>";

Now the component displays perfectly but the data will not bind the to controls, I have used the same IDs that the normal control generates?? Any idea how to get the data to bind correctly?

One way that I can think of is to put hidden text fields and assign the value OnChange using rbf_setField, sure this will work but seems very clunky when I would imagine the above code should bind?



All Replies

Posted by Godfrey Sorita on 05-Jan-2015 12:12

Hi Byron,

A more efficient way in achieving this is to append the rowspan HTML attribute to the <td> element. If your main purpose is to set the rowspan attribute the of the table cell, then paste the code below to a script component on your page:

$(function() {
  $("#rbi_F_contactType").attr('rowspan', '2');

You should be able see the results after refreshing the page. 



Posted by ByronB on 06-Jan-2015 13:34

Thanks Godfrey. You are right is much more efficient.  One question though is what if I wanted a group of check boxes but I want each checkbox to store it's true / false value. Currently you can have only one check box per td  cell. If you choose check box group all the values are stored in one field? 28th 5 he same code above but building the check box group how would I get the data to bind?

Posted by pvorobie on 06-Jan-2015 13:43

Please be aware that using actual IDs in scripts or formulas is not recommended: when you export your Application as XML and install into another Tenant, these IDs will be re-generated and your formula/script will no longer work. For that reason try using templates and API.

Posted by Godfrey Sorita on 06-Jan-2015 15:18
Unfortunately, I also can't bind data using elements generated from JavaScript. I typically use these elements as temporary fields(for display) wherein the values are stored on an field(hidden) of Rollbase.

Frankly, I don't recommend this approach as it would require a lot of work. The script should be updated when installing to other zones because group of checkboxes input IDs differ from every zone. It should also be able to handle Rollbase validations and be compatible to all browsers.
Posted by ByronB on 06-Jan-2015 15:29
Yeah my thoughts too. Will stick with standard UK regarding this. Does make for a clunky interface a bit. Thanks dude

This thread is closed