Need to remove preselected value from datasource in dropdown

Hi.
I am using ViewBag as datasource for providing vales in dropdown called Skills
We have 9 fields like skill1, skill2.......skill9. Once we select one value at skill1 should not be displayed in dropdown skill2 and so on.

   <div id="dvSkill1" class="col-sm-4">
                        <div class="form-group label-floating is-empty">

                            <ej-drop-down-list id="ddlSkill1"  datasource="ViewBag.Skills"  ej-for="SkillId1" change="serviceList_change" 
                                               EnablePopupResize="true" Width="100%">
                                <e-drop-down-list-fields text="Name" value="Id" />
                            </ej-drop-down-list>

                        </div>
                    </div>
                    <div id="dvSkill2" class="col-sm-4">
                        <div class="form-group label-floating is-empty">

                            <ej-drop-down-list id="ddlSkill2" datasource="ViewBag.Skills" enable-filter-search="true" ej-for="SkillId2" 
                                               EnablePopupResize="true" Width="100%">
                                <e-drop-down-list-fields text="Name" value="Id" />
                            </ej-drop-down-list>

                        </div>
                    </div>
                    <div id="dvSkill3" class="col-sm-4">
                        <div class="form-group label-floating is-empty">

                            <ej-drop-down-list id="ddlSkill3" datasource="ViewBag.Skills" enable-filter-search="true" ej-for="SkillId3" 
                                               EnablePopupResize="true" Width="100%">
                                <e-drop-down-list-fields text="Name" value="Id" />
                            </ej-drop-down-list>

                        </div>

How i can implement the jquery such that the dropdown should not display preselected value? as i need to update the datasource again and again

Thanks
Manish Tiwari



3 Replies

KV Karthikeyan Viswanathan Syncfusion Team August 17, 2018 08:53 AM UTC

Hi Manish, 

 Based on your scenario, you can clear the selected values by using cleartext public method or you can assign a null value to value property. Also, you can assign a data dynamically by using dataSource property. 

Please refer the below code example: 

<code> 

<ej-drop-down-list id="ddlSkill1"  datasource="ViewBag.Skills"  ej-for="SkillId1" change="serviceList_change"  
                                               EnablePopupResize="true" Width="100%" create="drpcreate" popup-hide="drppopuphide" popup-shown="drppopupshow" before-popup-shown="drpbeforepopupshow" change="drpvaluechange" select="drpselectchange"> 
                                <e-drop-down-list-fields text="Name" value="Id" /> 
                            </ej-drop-down-list> 

</code> 

<code> 
function drpselectchange(sender) {   var target = $("#ddlSkill2").data("ejDropDownList");       target.option({dataSource : data}); // you can change the data dynamically   target.option({value : null}); // you can remove the preselection         }

</code> 

Select – event triggers when items selected from DropDownList. 

Change – event triggers when value change. 

Create – event triggers when control created. 

Refer the below  API reference link: 



Regards, 
Karthikeyan V. 



MA Manish August 17, 2018 10:08 AM UTC

Thanks a lot !!!!! I got it.


SK Shanmugaraja K Syncfusion Team August 20, 2018 11:24 AM UTC

Hi Manish, 
 
Most welcome, please let us know if you need any assistance. 
 
Regards, 
Shanmugaraja K 


Loader.
Up arrow icon