比较extjs中的两个json数据

时间:2013-03-23 09:13:50

标签: json extjs

我有一个带有LeaveTypeName的json,而id.i有另一个json,只有id.how我得到LeavetypeName到第二个json的指定ID。第二个json只带有ID和其他一些数据,但我需要LeavetypeName为要显示的特定ID!请帮忙

  

第一个带有ID和LeavetypeName的json

 {
        "LeaveTypes": [
            {
                "ID": 60,
                "LeavetypeName": "Casual Leave"
            },
            {
                "ID": 61,
                "LeavetypeName": "Sick Leave"
            },
            {
                "ID": 62,
                "LeavetypeName": "Privilege Leave"
            },
            {
                "ID": 63,
                "LeavetypeName": "Maternity Leave"
            },
            {
                "ID": 64,
                "LeavetypeName": "Hospitalization Leave"
            },
            {
                "ID": 65,
                "LeavetypeName": "Bereavement Leave"
            },
            {
                "ID": 66,
                "LeavetypeName": "Medical Leave"
            },
            {
                "ID": 67,
                "LeavetypeName": "Paternity Leave"
            },
            {
                "ID": 68,
                "LeavetypeName": "Compensatory Leave"
            },
            {
                "ID": 69,
                "LeavetypeName": "Loss of Pay Leave"
            }
        ]
    }
  

第二个json.it有LeaveTypeId而不是我想在显示中显示Leavetypename。

[
    {
        "ID": 37,
        "LeaveEligibility": [
            {
                "Availed": 4,
                "Fullpaydays": 6,
                "Halfpaydays": 0,
                "ID": 1,
                "LeaveTypeId": 60,
                "PersonId": 37,
                "YearOfLeave": 2013
            },
            {
                "Availed": 2,
                "Fullpaydays": 6,
                "Halfpaydays": 0,
                "ID": 3,
                "LeaveTypeId": 61,
                "PersonId": 37,
                "YearOfLeave": 2013
            },
            {
                "Availed": 10,
                "Fullpaydays": 10,
                "Halfpaydays": 0,
                "ID": 4,
                "LeaveTypeId": 62,
                "PersonId": 37,
                "YearOfLeave": 2013
            },
            {
                "Availed": 0,
                "Fullpaydays": 8,
                "Halfpaydays": 0,
                "ID": 6,
                "LeaveTypeId": 63,
                "PersonId": 37,
                "YearOfLeave": 2013
            }
        ],
        "LeaveHistory": [
            {
                "AppliedTo": "Vibha",
                "ApprovalDate": "3/12/2013 12:00:00 AM",
                "ApprovedBy": 12,
                "Duration": 3,
                "FromDate": "3/24/2013 12:00:00 AM",
                "FullPayDays": 3,
                "HalfPayDays": 0,
                "ID": 1,
                "LeaveTypeId": 60,
                "LossOfPayDays": 0,
                "PersonId": 37,
                "Remarks": "onnulla",
                "StatusId": 79,
                "SubstitutePersonId": 13,
                "ToDate": "3/26/2013 12:00:00 AM"
            },
            {
                "AppliedTo": "Vibha",
                "ApprovalDate": "3/12/2013 12:00:00 AM",
                "ApprovedBy": 12,
                "Duration": 1,
                "FromDate": "3/30/2013 12:00:00 AM",
                "FullPayDays": 1,
                "HalfPayDays": 0,
                "ID": 2,
                "LeaveTypeId": 60,
                "LossOfPayDays": 0,
                "PersonId": 37,
                "Remarks": "onnulla",
                "StatusId": 79,
                "SubstitutePersonId": 13,
                "ToDate": "3/31/2013 12:00:00 AM"
            },
            {
                "AppliedTo": "Shyam",
                "ApprovalDate": "",
                "ApprovedBy": 0,
                "Duration": 2,
                "FromDate": "2/13/2013 12:00:00 AM",
                "FullPayDays": 2,
                "HalfPayDays": 0,
                "ID": 4,
                "LeaveTypeId": 61,
                "LossOfPayDays": 0,
                "PersonId": 37,
                "Remarks": "blha blah",
                "StatusId": 70,
                "SubstitutePersonId": 1,
                "ToDate": "2/14/2013 12:00:00 AM"
            },
            {
                "AppliedTo": "Shyam",
                "ApprovalDate": "2/13/2013 4:35:16 PM",
                "ApprovedBy": 2,
                "Duration": 5,
                "FromDate": "3/23/2013 12:00:00 AM",
                "FullPayDays": 5,
                "HalfPayDays": 0,
                "ID": 5,
                "LeaveTypeId": 62,
                "LossOfPayDays": 0,
                "PersonId": 37,
                "Remarks": "oh..",
                "StatusId": 71,
                "SubstitutePersonId": 1,
                "ToDate": "3/27/2013 12:00:00 AM"
            },
            {
                "AppliedTo": "Shyam",
                "ApprovalDate": "2/13/2013 4:35:16 PM",
                "ApprovedBy": 2,
                "Duration": 5,
                "FromDate": "3/28/2013 12:00:00 AM",
                "FullPayDays": 5,
                "HalfPayDays": 0,
                "ID": 6,
                "LeaveTypeId": 62,
                "LossOfPayDays": 0,
                "PersonId": 37,
                "Remarks": "oh..",
                "StatusId": 71,
                "SubstitutePersonId": 1,
                "ToDate": "3/29/2013 12:00:00 AM"
            }
        ],
        "PLavailedcount": 2
    }
]

1 个答案:

答案 0 :(得分:0)

您是否尝试过:

Ext.data.JsonStore.findRecord( fieldName, value, [startIndex], [anyMatch], [caseSensitive], [exactMatch] ) : Ext.data.Model

文档here