setCellValue() method throws "Cannot read property 'replace' of undefined"

Hey guys!

I'm attempting to implement a grid with a checkbox that causes some other cells to be recalculated. I searched the forums and found some really helpful posts to get the majority of what I need in place. 

However, my next step is actually changing the cells value to the new value, and when I call the setCellValue() method I get an error that doesn't seem to make sense. 

I'm using nuget package: Syncfusion.EJ2.AspNet.Core (17.4.0.51)

Below I've attached the view containing the test code that I'm unable to get work so far.

I appreciate any information you may have

Thank you!


Attachment: Index_179eb497.zip

5 Replies

TS Thiyagu Subramani Syncfusion Team February 27, 2020 12:48 PM UTC

Hi Montgomery, 

Thanks for contacting Syncfusion forum. 

We have prepared a sample as per your reported code snippet and NuGet package(17.4.0.51). But unfortunately we couldn’t reproduced it. Please refer to the below code, screenshot and sample . 

Here we have changed CustomerID value as testvalue which row contains primary key as 10001

function complete(args) { 
        var gridObj = document.getElementById('Grid1').ej2_instances[0]; 
 
        if (args.requestType === 'save') {              
            gridObj.setCellValue(10001, "CustomerID", "testvalue"); 
            // 10001 - Specifies the PrimaryKey value of dataSource. 
            // CustomerID - Specifies the field name which you want to update.  
           // testvalue - To update new value for the particular cell. 
        } 
    } 


NuGet package : 

 

Output :  
 
 
 
 
Still facing the issue, please share below details. 

  1. Share Syncfusion package version.
  2. You facing an issue in any specific browser?
  3. Pictorial or video representation of your issue.
 
Please get back to us, if you need any further assistance. 

Regards, 
Thiyagu S. 



MO Montgomery February 27, 2020 04:46 PM UTC

Hey Thiyagu,

Thanks for the reply, for some reason I was incorrectly trying to pass in the rowIndex rather than the primary key value.  

I corrected that and also changed the grid declaration to specify primary key on the Id field. 

Unfortunately I've still been unable to get it to function, I'm no longer getting the error however.

I've tested this in chrome and edge browsers, I have attached a problem step recording of my issue showing the code, browser steps and the chrome debugger as well as a screenshot of my project syncfusion reference. 

Thanks again!

Attachment: EditGrid_Issue_88e95e7a.zip


TS Thiyagu Subramani Syncfusion Team February 28, 2020 10:12 AM UTC

Hi Montgomery, 

Thanks for your update. 

Based on your attached screenshots we suspect that the issue may occur that you have passed primary key value in array type (args.primaryKeyValue returns the value in array type) in setCellValue method of EJ2 Grid. Please refer the below image. 

 

But it will accept the value in number/string based on corresponding primary key column value in dataSource. Please refer the below image. 

 
To achieve your requirement we suggest you to use the below code. Here you can get specific row’s primary key value using args.data[args.primaryKey].  

function complete(args) { 
        var gridObj = document.getElementById('Grid1').ej2_instances[0]; 
 
        if (args.requestType === 'save') {      
            gridObj.setCellValue(args.data[args.primaryKey], "CustomerID", "testvalue"); 
            // 10001 - Specifies the PrimaryKey value of dataSource. 
            // CustomerID - Specifies the field name which you want to update.  
            // testvalue - To update new value for the particular cell. 
        } 
    } 

(or) 

Note : You can also use args.primaryKeyValue[0] to specific row’s primary Key value 

Please get back to us, if you need any further assistance. 

Regards, 
Thiyagu S. 



MO Montgomery February 28, 2020 03:28 PM UTC

Hey Thiyagu, 

That's exactly what I was doing wrong, changing to the value and it works as expected. 

Such a silly mistake, but I appreciate your help getting me on track again. 

Thank you!!



MS Manivel Sellamuthu Syncfusion Team March 2, 2020 09:10 AM UTC

Hi Montgomery, 

Thanks for your update. 

We are happy to hear that your requirement has been achieved. 

Please get back to us, if you need further assistance. 

Regards, 
Manivel 


Loader.
Up arrow icon