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 do i get the value of the cell on singleClick

Hi,

how do i get the value in a single click checkbox to invert it? 

Kind regards,
michael

3 Replies

Dhivya Rajendran February 11, 2020 02:06 PM UTC

Hi Michael, 

Greetings from Syncfusion Support. 

Query: how do i get the value in a single click checkbox to invert it?  
 
We suspect that you need to get the data , when you click on a row. You can achieve your requirement by using the rowSelected event of Grid. In the rowSelected event you can get the details such as rowIndex, rowElement and row data. Please refer to the sample code below and sample link for more information. 


<ejs-grid  
                 :rowSelected="rowSelected"> 
                 . 
              </ejs-grid>    

rowSelected: function(args){ 
      console.log(args.data); 
      //You can get the Row details in rowSelected event 
    } 
  
  
If we have misunderstood your query, please share more or below details that will be helpful for us to analyze further at our end. 

  1. Please share your requirement more briefly.
  2. Please share your Grid code example

Regards, 
R.Dhivya 
  
  


MK Michael Kornatzki February 11, 2020 02:13 PM UTC

Hi,

in the eample 

      load: function() {
        this.$refs.grid.ej2Instances.element.addEventListener('mousedown', function(e) {
          var instance = this.ej2_instances[0];
          if (e.target.classList.contains("e-rowcell")) {
            let index = parseInt(e.target.getAttribute("Index"));
            let colindex = parseInt(e.target.getAttribute("aria-colindex"));
            let field = instance.getColumns()[colindex].field;
            instance.editModule.editCell(index, field);
          };
        });

i have a editorModule.
I was hoping that i can get the value somehow and can update the cell.

I want to click on a checkboxrenderer and the value should change without opening the editor.

Kind regards,
Michael 




Dhivya Rajendran February 12, 2020 03:44 PM UTC

Hi Michael, 

Thanks for sharing the details. 

We have analyzed your requirement and you can achieve this by using the below way. In the below sample, we have used the same way like single click editing in batch mode but in that mousedown event of Grid we have checked the columns is checkbox column(Verified) or not and if its checkbox column then we have used updateCell method instead of editCell to update the checkbox value in Grid. 

Please refer the below code example and sample for more information. 

load: function(args) { 
      this.$refs.grid.ej2Instances.element.addEventListener( 
        "mousedown", 
        function(e) { 
          var instance = this.ej2_instances[0]; 
          if (e.target.classList.contains("e-rowcell")) { 
            let index = parseInt(e.target.getAttribute("Index")); 
            let colindex = parseInt(e.target.getAttribute("aria-colindex")); 
            let field = instance.getColumns()[colindex].field; 
            if (field === "Verified") { 
              instance.editModule.updateCell(index, field, e.target.querySelector(".e-check") ? false : true 
              ); 
            } else { 
              instance.editModule.editCell(index, field); 
           
         
       
      ); 
   



Please get back to us if your require further assistance on this. 

Regards, 
R.Dhivya 

Loader.
Live Chat Icon For mobile
Up arrow icon