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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Multiples dropdownlist with check all

Thread ID:

Created:

Updated:

Platform:

Replies:

128050 Dec 28,2016 07:18 PM UTC Jan 3,2017 04:19 AM UTC ASP.NET MVC 3
loading
Tags: DropDownList
Manolo
Asked On December 28, 2016 07:18 PM UTC

Hi,

In this article, you explain how set a check all in drop down list.

https://help.syncfusion.com/aspnetmvc/dropdownlist/howto

But I've a lot of drop down with this capabilities. I don't like define the same function for check or uncheck for each drop down.

The code
function create(args) {
            $("#check").ejCheckBox({ text: "Check All", change: "onallChange" });
        }
        function onallChange(args) {
            window.flag = true;
            var obj = $("#DropDownList1").ejDropDownList("instance");
            if (args.isChecked) obj.checkAll();
            else obj.uncheckAll();
            window.flag = false;
        }
How can I pass at function "onallChange" the drop down owner as parameter. Thus, this function can be generic.

Alternative solutions are welcome also

Thanks!

Karthikeyan Viswanathan [Syncfusion]
Replied On January 2, 2017 08:41 AM UTC

Hi Manolo, 

 Thanks for Contacting Syncfusion Support. 

You can add generic check all option in dropdownlist by using below code snippet: 

<code> 
function create(args) { 
        $(".e-dropdownlist.check").ejCheckBox({ text: "Check All", change: "onallChange" }); 
    } 
    function onallChange(args) { 
        window.flag = true; 
        var obj = $("#" + this.element.parents(".e-ddl-popup").attr("id").replace("_popup_list_wrapper", "")).ejDropDownList("instance"); 
        if (args.isChecked) obj.checkAll(); 
        else obj.uncheckAll(); 
        window.flag = false; 
    } 
</code> 


Regards, 
Karthikeyan v. 


Manolo
Replied On January 2, 2017 07:09 PM UTC

Hi,

Your code works perfectly, thanks, but I've other problem.

If I set all dropdowns in a form, if I set this definition in the controller

        [HttpPost]
        public JsonResult Filtrar(string ddlComunidad, string ddlProvincia, ddlSituacionMunicipio)
        {
            var datos = GetNNPP(ddlComunidad, ddlProvincia, ddlSituacionMunicipio)ToList();
            return Json(datos);
        }

I only get the first value cheked, not all values.



Karthikeyan Viswanathan [Syncfusion]
Replied On January 3, 2017 04:19 AM UTC

Hi Manolo,  
 
 You can’t get the collection of selected items with in string argument otherwise you can get the items in list of string. You can get all checked items in dropdownlist by using below code snippet:  
 
<code>  
[HttpPost] 
        public JsonResult Filtrar(List<string> ddlComunidad, List<string> ddlProvincia) 
        { 
   
            return Json(ddlComunidad,JsonRequestBehavior.AllowGet); 
        } 
</code>  


 
Regards,  
Karthikeyan v.  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;