0

I have the following code :-

var dataSub = [];

 $.each(dataObj.EmployeeDetail, function (idx, obj) {
            $.each(columnDb, function (idx1, obj1) {
            dataSub.push(obj[obj1.title]);
     });
});

In dataObj.EmployeeDetail I have data like this :-

   Object 0 : { Address1: "123",Address2: null,Category: 1,Children: 0,City: "Xyxz" }
   Object 1 : { Address1: "456",Address2: null,Category: 1,Children: 0,City: "Abc" }

In columnDb I have data like this :-

Object 0 : title: "ADDRESS1"
Object 1 : title: "CITY"

As you can see the data in columnDB is in uppercase(dynamic data), my dataSub always remains empty because title it is not matching with dataObj.EmployeeDetail.

How to solve this issue?

Anup
  • 9,396
  • 16
  • 74
  • 138

1 Answers1

0

Try this:

    var dataSub = [];
    $.each(dataObj.EmployeeDetail, function(idx, obj) {
        var array = $.map(obj, function(value, index) {
            return [value];
        });
        dataSub.push(array);
        $.each(columnDb, function(idx1, obj1) {
            dataSub[idx].push(obj1.title);
        });
    });
    console.log(dataSub);
CodeGodie
  • 12,116
  • 6
  • 37
  • 66