0

I have a grid data and I push new data to him. The new data must contain at least one value to be different.

I've try this:

vm.checkUnique = function () {
    var gridData = vm.sanctionReferencesGridOptions.data;
    var formData = vm.editableGrid.newRowForm;
    for (var i = 0; i < gridData.length; i++) {
        var rowData = gridData[i]
        for (var key in rowData) {
            console.log('rowData: ' + key);
            for (var formKey in formData) {
                console.log('formKey: ' + formKey);
            }
        }
    }
}

vm.sanctionReferencesGridOptions.data = [
    {
        "code": 1111,
        "listName": "List 1",
        "sinceDate": "2017-08-23",
        "endDate": "2017-08-23"
    }, {
        "code": 2222,
        "listName": "List 2",
        "sinceDate": "2017-08-23",
        "endDate": "2017-08-23"
    }
 ]

vm.editableGrid.newRowForm = {
    code: "1111", 
    listName: "List 1", 
    sinceDate: "2017-08-23", 
    endDate: "2017-08-23"
}

So in this example I must show an error message with duplicated row data..

Thanks for any help!

Carnaru Valentin
  • 1,690
  • 17
  • 27
  • 1
    Great! Do your research, [search](/help/searching) for related topics on SO, and give it a go. ***If*** you get stuck and can't get unstuck after doing more research and searching, post a [mcve] of your attempt and say specifically where you're stuck. People will be glad to help. More: [*How do I ask a good question?*](/help/how-to-ask) Good luck! – T.J. Crowder Nov 28 '17 at 09:08
  • Is not duplicated, the is Object vs. Object, here is Array of objects vs. Object. – Carnaru Valentin Nov 28 '17 at 09:20
  • (For the record: No, I didn't vote to close as duplicate. [SO gets that wrong](https://meta.stackexchange.com/questions/269073/dont-say-i-marked-something-as-a-duplicate-when-i-didnt). But Alexandru-Ionut is right.) – T.J. Crowder Nov 28 '17 at 09:23
  • So you're saying you can't manage to apply a loop to the linked solution? – T.J. Crowder Nov 28 '17 at 09:25

0 Answers0