custom picklist field renderer displays array as one of the entries

Pat VachonPat Vachon πŸ’ŽπŸ’ŽπŸ’Ž
edited June 25, 2020 in Questions



Comments

  • Amy DewaalAmy Dewaal ✭✭
    edited June 25, 2020
    Pat,

    That's pretty odd. What version of Skuid are you on?

    Thanks!
    Amy
  • Pat VachonPat Vachon πŸ’ŽπŸ’ŽπŸ’Ž
    edited November 14, 2016
    8.15.15
  • edited June 25, 2020
    Hi Pat,

    It looks like the whole roleUserPicklist gets added to the field metadata (try looking at model.fields[x].picklistEntries where x = the index of your field).
    Try thisΒ skuid.ui.fieldRenderers.PICKLIST.edit(field, roleUserPicklist) instead of adding the field metadata in skuid.ui.fieldRenderers.PICKLIST.edit(field, field.metadata.picklistEntries)).

    Maybe that helps.

    Keep me posted ;)

    Cheers
  • Pat VachonPat Vachon πŸ’ŽπŸ’ŽπŸ’Ž
    edited November 14, 2016
    My favourite Skuid Dev from Europe!! How you doin?

    I tried this to no avail. Both result in the same experience.

    When looking at the model.field[3].picklistEntries, I get the following:

    image


    Looks fine to me.
  • edited December 15, 2016
    Hey Pat, my favourite Skuid Dev from Canada :D
    I'm fine, how is life treating you?

    Yep, the model metadata looks fine but that still doesn't explain the (very) odd behaviour of that renderer...
    There's one workaround where you just simply delete the first entry of the rendered HTML-picklist (which you can get using field.element as starting node after skuid.ui.fieldRenderers...)Β , since it only seems to affect the first entry (pretty hacky and ugly, but that should work ^^)

    This could look like this:
    skuid.ui.fieldRenderers.PICKLIST.edit(field, roleUserPicklist);
    $(field.element).find("option").eq(0).remove();
    You might need to modify that a little, didn't test that ;)

    Keep me posted ;)

    Cheers
  • Pat VachonPat Vachon πŸ’ŽπŸ’ŽπŸ’Ž
    edited November 14, 2016
    Ugh ... really don't want to use a workaround. Going to create a test page to isolate this later this evening.
  • edited December 15, 2016
    Haha, no one does :P

  • Pat VachonPat Vachon πŸ’ŽπŸ’ŽπŸ’Ž
    edited June 25, 2020
    Ok. Created this test page using standard objects and I'm getting the same behaviour. :S
    <skuidpage showsidebar="false" showheader="false" tabtooverride="Opportunity" unsavedchangeswarning="" theme="Modern" personalizationmode="server">      <resources>          <labels/>          <javascript>              <jsitem location="inlinesnippet" name="AssignedTo" cachelocation="false">var field = arguments[0],      $ = skuid.$,      Users = skuid.$M('Users'),      picklistEntries = [];        $.each(Users.getRows(), function(r,row){          picklistEntries.push(                 { value: row.Id , label: row.Name, defaultValue: (r == 1 ? true : false), active: true  }              );          });        field.metadata.picklistEntries = picklistEntries;        skuid.ui.fieldRenderers.PICKLIST.edit( field, picklistEntries );</jsitem>          </javascript>          <css/>      </resources>      <models>          <model id="Users" limit="20" query="true" createrowifnonefound="false" sobject="User" adapter="salesforce" type="">              <fields>                  <field id="Id"/>                  <field id="Name"/>              </fields>              <conditions>                  <condition type="fieldvalue" value="true" enclosevalueinquotes="false" field="IsActive"/>              </conditions>              <actions/>          </model>          <model id="Tasks" limit="20" query="true" createrowifnonefound="false" adapter="salesforce" type="" sobject="Task">              <fields>                  <field id="OwnerId"/>                  <field id="Owner.Name"/>              </fields>              <conditions/>              <actions/>          </model>      </models>      <components>          <skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="false" showexportbuttons="false" pagesize="10" createrecords="false" model="Tasks" buttonposition="" mode="edit" emptysearchbehavior="query" allowscrollbars="false" floatheader="false" tablescrollheight="" uniqueid="sk-1fEbjT-132">              <fields>                  <field id="OwnerId" valuehalign="" type="CUSTOM" snippet="AssignedTo" required="true"/>              </fields>              <rowactions/>              <massactions usefirstitemasdefault="true"/>              <views>                  <view type="standard"/>              </views>              <searchfields/>              <conditions/>              <renderconditions logictype="and"/>          </skootable>      </components>      <styles>          <styleitem type="background" bgtype="none"/>      </styles>  </skuidpage>
    Β 


  • edited December 15, 2016
    Hey Pat, I just found your problem.

    It was in this line:
    skuid.ui.fieldRenderers.PICKLIST.edit(field, picklistEntries);
    Specifically the second argument for the rendering method. This usually is the value of the field (in this case the selected user for the assigned task). When you pass in an object to that, it gets converted to a string which gets you the [object object] notation.

    This is what I came up with. You maybe don't need the selectedName part and add in the defaultValue-property again. In order to add a default value, just create a new variable and assemble the appropriate string value for it and pass it instead of selectedName.Name.
    I also cleaned up the snippet to make it more performant :P
    var field = arguments[0],Β  Β      value = arguments[1],
    Β  Β  $ = skuid.$,
    Β  Β  Users = skuid.$M('Users'),
    Β  Β  selectedName = Users.getRowById(value);
    field.metadata.picklistEntries = [];
    $.each(Users.getRows(), function(r,row){
    Β  Β  field.metadata.picklistEntries.push({value: row.Id, label: row.Name, active: true}); Β  Β 
    });
    skuid.ui.fieldRenderers.PICKLIST.edit(field, selectedName.Name);
    This is the outcome:

    image

    Cheers
  • Pat VachonPat Vachon πŸ’ŽπŸ’ŽπŸ’Ž
    edited November 21, 2016
    Got it working with this pointing me in the right direction. Thanks for helping me remove the cobwebs off my field renderer skills.
  • edited December 15, 2016
    Always glad to help ;)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!