Service Portal Widget's dropdown

Dhruv Chandan
Giga Guru

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:-

find_real_file.png

Any help is appreciated on the scrip to add options to the above drop down.

Regards,

Dhruv Chandan

1 ACCEPTED SOLUTION

Justin Abbott
Giga Guru

<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>


View solution in original post

14 REPLIES 14

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);


}


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.


Hi @arshanapalli 

 

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

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

teroruuskanen
Giga Contributor

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