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
close icon

Checkbox does not check when clicked

The title says it all. When I click on the checkbox, there is no change of state of checkbox to Checked

My model:

    public class TituloPendente
        public int TituloID { get; set; }
        public bool Selecionado { get; set; }
        public string NumeroDoDocumento { get; set; }
        public string NossoNumero { get; set; }
        public DateTime DataDeVencimento { get; set; }
        public decimal Valor { get; set; }

My Home Controller:

    public class HomeController : Controller
        private static readonly object objLock = new object();

        public ActionResult Index()
            List<SyncfusionMvcApplication1.Models.TituloPendente> titulos = new List<Models.TituloPendente>();

            for (int i = 0; i < 100; i++)
                Random rnd = new Random((int)Math.Cos((double)(i + 1)));

                lock (objLock)
                    titulos.Add(new Models.TituloPendente()
                        TituloID = 1,
                        NumeroDoDocumento = (i + 1 * 8454548).ToString(),
                        NossoNumero = (i + 1 * 6544456).ToString(),
                        DataDeVencimento = DateTime.Now.AddDays(i),
                        Valor = (decimal)((15.02m * (i + 1)) + (decimal)((double)((i + 1) % 45646) / Math.Sqrt((double)(rnd.Next(1, 45645646))))),
                        Selecionado = false

            return View(titulos);

My View:
 ( in attachment )

Attachment: Index_dd8257a4.zip

3 Replies

PK Padmavathy Kamalanathan Syncfusion Team October 31, 2019 02:40 AM UTC

Hi Alexandre,

Thanks for contacting Syncfusion Forums.

QUERY: CheckBox doesn't check when clicked

From the code you have shared, we can undestand that you are using "displayAsCheckbox" property for showing the column as check box column. When you use "displayAsCheckbox" property, you can check/uncheck it in edit mode(by double clicking the cell). 

Please let us know the below details, so that we can help you to achieve it,
1) Whether you need to check/ uncheck in single click
2) Please explain us your requirement with clarity(what you are trying to do with the check box)
3) Version Details
4) Screenshot of error with stacktrace(if any)

If you have further queries, please get back to us.

Padmavathy Kamalanathan

AL Alexandre November 1, 2019 09:07 PM UTC

Hi! I just need to have a checkbox to select some rows of the grid and send this selected rows to the controller... ( When change the page, the selection can't be lost )

PK Padmavathy Kamalanathan Syncfusion Team November 5, 2019 03:38 AM UTC

Hi Alexandre,

Thanks for your update.

QUERY: Need to select some rows and send to controller 

From your query we understand that you need to select rows using checkbox and send the selectes rows to the controller. This can be done by following below steps,

1) Render checkbox as column using type property. Please check below help documentation,

2) Select checkboxes and in actionComplete event with requestType as "paging", you can get the selected records's primary key value and save it to array when you navigate from one page to other.
Please check below help documentations,

3) In button click event, using AJAX, you can send the selected Record's primary key value to controller. In Controller, you can compare the passed primary key value with your data model and perform your functionalities.

Please check below code,

@Html.EJ().Button("mute").Size(ButtonSize.Large).ShowRoundedCorner(true).ClientSideEvents(e => e.Click("click")).Text("Mute")

                                .ClientSideEvents(eve => { eve.ActionComplete("actionComplete"); })
                                .Columns(col =>
                                    col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();

    var primaryKeyValuesArray = []; 
    function click(args) {
        var selectedData = primaryKeyValuesArray; // array of primary key values

              // pass to controller
    function actionComplete(args) {
        if (args.requestType == "paging") { 
            var data1 = this.model.selectedRecords, len1 = data1.length, arrayLength = primaryKeyValuesArray.length;
            for (i = 0; i < len1; i++) {
                var value = data1[i]["OrderID"]; // orderID is primarykey column field

If you have further queries. please get back to us.

Padmavathy Kamalanathan

Live Chat Icon For mobile
Up arrow icon