Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
How to bind list of objects to handsontable?

I have a json object,which contains following data.

var myData = [{
        "sNo": "1.0",
        "boqName": "Installation of pole 11 KV",
        "unit": "Nos",
        
        "opportunityBoqOverHeadMasterList": [{
                "opportunityBoqOverHeadMasterId": 14,
                "value": 41.3
            },
            {
                "opportunityBoqOverHeadMasterId": 16,
                "value": 41.3
            },
            {
                "opportunityBoqOverHeadMasterId": 24,
                "value": 100
            }
        ]
    },
    {
        "sNo": "2.0",
        "boqName": "Installation of pole 33 KV",
        "unit": "Nos",
       
        "opportunityBoqOverHeadMasterList": [{
                "opportunityBoqOverHeadMasterId": 15,
                "value": 52.92
            },
            {
                "opportunityBoqOverHeadMasterId": 17,
                "value": 52.92
            },
            {
                "opportunityBoqOverHeadMasterId": 25,
                "value": 0
            }
        ]
    },

];

}

i need to display the value of opportunityBoqOverHeadMasterList next to the unit cell. Please help me to display data in handsontable.
Please refer jsfiddle for working example https://jsfiddle.net/Umanath16/aty5wfg7/22/

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could try processing the data. Notice below that I changed your columns array, create a new myNewData variable and create nested loops to format the data.

    var columns = [
        {
            "data": "sNo"
        },
        {
            "data": "boqName"
        },
        {
            "data": "unit"
        },
        ,
        {
            "data": "Percentage1"
        },
        {
            "data": "Percentage2"
        },
        {
            "data": "Percentage3"
        }
    ];

Change the data obj...

    var myNewData = [];
    
    for (var i = 0; i < myData.length; i++) {
        myNewData.push({
          sNo: myData[i].sNo,
          boqName: myData[i].boqName,
          unit: myData[i].unit
        });
        for (var j = 0; j < myData[i].opportunityBoqOverHeadMasterList.length; j++) {
          myNewData[i]["Percentage"+(j+1)] = myData[i].opportunityBoqOverHeadMasterList[j].value;
        }
    }

    hot = new Handsontable(example, {
        data: myNewData,
        rowHeaders: true,
        columns: columns,
        rowHeaderWidth: 100,
        colWidths: 120,
        colHeaders: colHeaders
    });
}

This is just one possible solution. Please think about possible improvements. What if the data does not have the same fields? It would need to be dynamic regardless of the field names. Also how would you improve the loops, etc.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!