Duplicate values should not be selected in dropdown

Hi

i have my webix code like below

webix.ui({

	view:"window",

	id:"moviewin",

	height:300,

	width:700,

	modal:true,

	position:"center",

	head:"Movie data",

	hidden: false, 

		body:{

			view:"form",id:"movieform",width:600, scroll: true, 

				 elements:[{

					view: "layout",

						cols:[	

							{

                              view:"combo",

                              id:"moviedata",

                              label:"Fields",

								options:[

									{id:"movie",value:"Movie Name",type:"string"},

									{ id:"movieplace", value:"Movie Place", type:"string"},

									{ id:"year", alue:"year", type:"string" },

								],

							},

						{

                          view:"text",

                          label:"Value"

                        },

		]

  },

	{

      cols:[

		{view:"button",


         label:"Movie Data",

         	click:function(){


   }},

		{view:"button", 

         label:"Reset",

         	click:function(){

	}},

		{view:"button", 

         label:"Cancel",

         	click:function(){


          }},

        {view:"button", 

         label:"Add",

         	click:function(){


				$$("movieform").addView({

					view: "layout",

						cols:[	

							{

                              view:"combo",

                              id:"moviedata",

                              label:"Fields",

								options:[
									{id:"movie",value:"Movie Name",type:"string"},

									{ id:"movieplace", value:"Movie Place", type:"string"},

									{ id:"year", alue:"year", type:"string" },
								],

							},

						{
                          view:"text",

                          label:"Value"

                        },
						{view:"icon", icon:"wxi-trash",click:function(){

           			      let toRemove = this.getParentView();

                          this.getParentView().getParentView().removeView(toRemove)

      					}}, 
						]}, 0);
              
          }},

        ]

	}

 ],
}
});

If the user selects the movie name in the combo . And clicks on the add button

if again for the combo in the row 2 if the user selects the movie name again.

i need to display a pop-up saying duplicate values selected.

How can i do that?

Hi,

Can anybody help me pls…:(:frowning:

Hi,

can anyone help me out …

Do we need to use ajax for this requirment?

hi @Nastja

Could you pls help me .

Hello @prasadraju ,

You can use onChange event for dynamically added combo as

{
   view:"combo",
   name:"co",
  ...
    on:{
          onChange: function(){ 
                           ...
                       }, 

Getting form element(combo in our case): $$("formID").elements['elementName']

To get the suggest list of combo: $$('formID').elements['elementName'].getList();

For example, if you don’t want to have duplicate values you can remove it with the help of splice(): https://snippet.webix.com/ewkk1flk

Hello @Natsja

In the above code we have a bug like

initially the drop down and textbox is displayed and i am selcting moviename in the dropdown.

When i click on the add button one more row which has combo and textbox is adding up.

I am selecting year1 as the value from the dropdown and filling the textbox as 2006

now clicking on the add button again one more row is getting added with values like moviename and movieplace as valuesfrom the dropdown .

I will select movieplace as the value and then fill the textbox with some value.

but when i click on the trash icon which belongs to year1 it is getting deleted.

but again if i click on the add button again the row which has combo and textbox is getting added but year1 value is missing from the dropdown.

Please advice what should be done in this case.

hi
Can somebody please help me …

Regards

Hi @Nastja

Can you please help …I tried it but no luck…

Hello @prasadraju ,

We made some changes in the code which I sent above.
Please check the sample: https://snippet.webix.com/iyz20vf2

Also, you can limit the adding of combos if all values are selected: https://snippet.webix.com/lkr0rwix