I have an array using MVC Model, which returns values of example data
var result = [{"Id":399,"Number":"Test09_05_2022","Name":"Test_10_03_2022","Status":"Inactive"},
{"Id":377,"Number":"000-1","Name":"New", "Status":"Inactive"},
{"Id":386,"Number":"000-8","Name":"NewEmployee", "Status":"Active"},
{"Id":382,"Number":"05 FEB 2020,"Name":"Test","Status":"Active"}]
I am trying to find all Inactive Status and a hide a add Button.
What I have tried:
var result = @Html.Raw(Json.Encode(Model));
result.forEach(function (e) {
var conStatus = e.Status;
if (conStatus === "Inactive") {
$("#AddButton").hide();
return true;
}
else (conStatus === "Active")
{
$("#AddButton").show();
return true;
}
return true;
});
This code is looping and defaulting to the first item and therefore hiding the Button even if it is Active. Any help will be appreciated.