- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 01:51 AM
Hi All,
I'm trying to create a drop-down field with some options in the Service Portal Widget, drop-down is created but i'm not sure as how can i add options to ti.
HTML script:-
<select type="text" id="mySelect" class="dropdown" ng-model="c.data.personalDetail.LevelOfAccess" required><select/>
i want the drop down to look like below, with the default option as none:-
Any help is appreciated on the scrip to add options to the above drop down.
Regards,
Dhruv Chandan
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 05:42 AM
<select type="text" id="mySelect" class="dropdown" ng-model="c.data.personalDetail.LevelOfAccess" required>
<option value="none" selected>None</option>
<option value="admin">Admin</option>
<option value="user">User</option>
</select>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2018 11:52 PM
See my example code from above. Since the drop-down value is set with the ng-model, you can update the server with "c.server.update()" and access the selected drop-down value in the server script with "input.personalDetail.LevelofAccess".
Example:
HTML:
<select id="mySelect" ng-init="c.data.personalDetail.LevelOfAccess = c.options[0]" ng-model="c.data.personalDetail.LevelOfAccess" ng-options="option.name for option in options" required></select>
Client script (come up with a condition on when to update the server, like ng-change on the dropdown):
c.server.update().then(function(response) {
console.log(response);
});
Server script:
if(input) {
console.log(input.personalDetail.LevelOfAccess.name);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2018 02:38 PM
Thanks Tero for the reply. It helped me, the only change I made was included ng-change tag to call the server update function whenever I changed the drop-down.
HTML:
<select id="mySelect" ng-init="c.data.dropDown.Value = c.options[0]" ng-model="c.data.dropDown.Value" ng-options="option.name for option in options" required ng-change="c.server.update()"></select>
Thanks,
Harsha.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2021 07:14 AM
Hi
I was unable to understand, that how I need to put filter condition in client script. Could you please share the client script code, It would be a great help to me.
Thank you,
Sanjay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2021 06:59 AM
I was unable to understand, that how I need to put filter condition in client script. Could you please share the client script code, It would be a great help to me.
Thank you,
Sanjay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 06:02 AM
Greetings,
You can populate the dropdown with options from client script using an array, and set the default selected option by setting the ng-model variable (c.data.personalDetail.LevelOfAccess) as the desired cell in the array.
Here is example code:
HTML:
<select id="mySelect" ng-init="c.data.personalDetail.LevelOfAccess = c.options[0]" ng-model="c.data.personalDetail.LevelOfAccess" ng-options="option.name for option in options" required></select>
Client script:
c.options = [{
name: 'None',
value: 'none'
}, {
name: 'Admin',
value: 'admin'
}, {
name: 'User',
value: 'user'
}];
You can get the currently selected option from client script using c.data.personalDetail.LevelOfAccess.value
Regards,
Tero Ruuskanen
Please Hit like, Helpful or Correct depending on the impact of the response