We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to submit all selected objects in Dual Listbox

Dear,

I have made a form based on the example on https://ej2.syncfusion.com/aspnetmvc/ListBox/DualListBox#/material

I use the left listbox (called Group A in the example) as a list of available options and the right listbox (group B) as the list of selected options.
When submitting my form, only the objects that are highlighted (selected) in Group B are being submitted with the formdata; only these selected items appear in the hidden field (e-hidden-select).

I want some way to select all the items in Group B before I submit the form, how can I do this? 

I tried somehow to select these items with some function to add the "e-selected" class the the UL items in the listbox, but that does not make them appear in the e-hidden-select list...

Thanks in advance,
Koen

3 Replies

CI Christopher Issac Sunder K Syncfusion Team May 29, 2019 09:33 AM UTC

Hi Koen, 
 
Greetings from Syncfusion support. 
 
We have checked your reported requirement “To select all options in the listbox” and we would like to let you know that your requirement can be achievable by using selectAll method as like in the below code example. 
 
Code Example: 
@Html.EJS().Button("btn").Content("To SelectAll Items").Render() 
 
document.getElementById("btn").addEventListener('click', function () { 
        var listbox2 = ej.base.getComponent(document.querySelector('#listbox2'), 'listbox'); 
        listbox2.selectAll(); 
    }) 
 
For your convenience, we have prepared the sample based on your requirement in a button click event. Please find the link below. 
 
 
Could you please check the above sample and get back to us, if you need any further assistance on this. 

Thanks,
Christo 



KO Koen May 29, 2019 10:12 AM UTC

Thanks, it's working! I have to make myself comfortable with the syncfusion functions instead of trying to use JS/Jquery to get it done.



VK Vinoth Kumar Sundara Moorthy Syncfusion Team May 30, 2019 07:14 AM UTC

Hi Keon,  
  
We are glad to know that your requirement is fulfilled with provided solution. Please get back to us if you need any further assistance on Syncfusion Components.  
  
Regards,  
Vinoth Kumar S  


Loader.
Up arrow icon