4

I have an aura:attribute of type string[] and I want that user should be able to populate the values in that string array through app builder. For this I am using design:attributes as;

Component:

<aura:attribute name="columnHeaders" type="String[]" access="global" description='column Headers' default="['name','Category','Price']"/>
.
.
.
<aura:iteration items="{!v.columnHeaders}" var="colHead">
<!-- some code -->
</aura:iteartion>

Design attribute:

<design:component label="Column Header">
    <design:attribute name="columnHeaders" Label="Column Header" description='column Headers' datasource="Name,Category,Price,Type,Location"/>
</design:component>

But the design attribute don't work with attribute of type String[].

Error: Failed to save undefined: Only String attributes may have a datasource in the design file.: Source

So when I make the attribute of type "String" instead of "String[]" and save in the app builder, it is showing me picklist of values as mentioned but it iterates over single picklist value string (like 'Location') to give me column headers as:

L O C A T I O N S

instead of:

Name Type Category Location

and so on.

  • I created 4 atributes each in aura:component and design:component. Then , in init of this component, populated 2 of these in attribute of type String[], thinking that on change of value in app builder, the String[] will get dynamic values. But in app builder it is giving me error : .push is not a function on initialisation. What to do in this case – Sarang Mar 7 '17 at 8:50
  • push should work, can you edit your question to add the related code ? – Fabien Taillon Mar 7 '17 at 11:49
2

Sorry this is currently not supported. Only String, Integer and Boolean is supported, where Strings can have a datasource that will present as a picklist. Reference: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_config_for_app_builder_design_files.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.