- Home
- Forum
- ASP.NET MVC
- Multiples dropdownlist with check all
Multiples dropdownlist with check all
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
Alternative solutions are welcome also
Thanks!
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!
SIGN IN To post a reply.
3 Replies
KV
Karthikeyan Viswanathan
Syncfusion Team
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> |
Please find the sample link: http://www.syncfusion.com/downloads/support/forum/128050/ze/Dropdownlistcheckallheadertemplate-1819133375.zip
Regards,
Karthikeyan v.
MA
Manolo
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.
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.
KV
Karthikeyan Viswanathan
Syncfusion Team
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> |
Please find the sample link: http://www.syncfusion.com/downloads/support/forum/128050/ze/Dropdownlistcheckallitem232801711.zip
Regards,
Karthikeyan v.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
MA Manolo
- Dec 28, 2016 07:18 PM UTC
- Jan 3, 2017 04:19 AM UTC