How to get cell data in Javascript?

Hello,


I am using JS2 plattaform, and I have defined a funcion for RowSelecting event on jsTreeGrid ("rowSelecting") using one of the samples on the forum.


The function looks like that:


        function rowSelecting(args) {

            console.info(args.data);

            console.info(args.data.taskId);

        }


 When it prints args.data to the console, I get the following:


{TaskId: 2, TaskName: 'Plan timeline', StartDate: '02/03/2017', EndDate: '02/07/2017', Duration: 5, …}
Approved: false
Children: null
Duration: 5
EndDate: "02/07/2017"
FilterEndDate: Tue Feb 07 2017 00:00:00 GMT-0200 (Horário de Verão de Brasília) {}
FilterStartDate: Fri Feb 03 2017 00:00:00 GMT-0200 (Horário de Verão de Brasília) {}
ParentId: null
Priority: "Normal"
Progress: 100
StartDate: "02/03/2017"
TaskId: 2
TaskName: "Plan timeline"
checkboxState: "uncheck"
index: 1
level: 1
parentItem: {TaskId: 1, TaskName: 'Planning', StartDate: '02/03/2017', EndDate: '02/07/2017', Duration: 5, …}
parentUniqueID: "TreeGrid_data_0"
taskData: {TaskId: 2, TaskName: 'Plan timeline', StartDate: '02/03/2017', EndDate: '02/07/2017', Duration: 5, …}
uniqueID: "TreeGrid_data_1"
[[Prototype]]: Object


But when it tries to print  args.data.taskId, I get an "undefined" output.


So, my question is, how to access the property content of the cell.


Regards,


Alexandre


2 Replies

AL Alexandre September 17, 2021 11:35 AM UTC

Hello,


I just found it. I had to put it between brackets: 

 

console.info(args.data['TaskId'])


Regards,


Alexandre



PS Pon Selva Jeganathan Syncfusion Team September 20, 2021 10:55 AM UTC

Hi Alexandre 
   
Thanks for contacting syncfusion forum. 
 

Query: How to get cell data in Javascript?

 
We are glad that you found the solution for the issue.  

Based on your code example, you have property value is not defined properly. So, its return undefined value. To avoid this problem, we recommend that you ensure the casing. 

Please refer to the below code example, 
 
 
Your Code: 
 
 function rowSelecting(args) { 
            console.info(args.data); 
            console.info(args.data.taskId); 
        } 
 
Modified code: 
selecting(args) { 
    console.log(args.data.TaskId); 
  } 
 
 
 
 
Kindly get back to us for further assistance.  
  
Regards, 
Pon selva 
 


Loader.
Up arrow icon