on 02-08-2017 10:30 AM
I have a local json model
like:
{
"CompliantCollection": [
{
"ComplaintId": "123",
"Name": "Software Installations",
"Description": "SAP NetWeaver AS ABAP 7.50 SP2 Developer Edition Installation on MAC O",
"TicketDate":"11/01/2017 12:50:50",
"CurrentOwner":"Admin",
"Address":"A-293,New Ashok Nagar,new Delhi",
"Status":"Pool"
}
]
}
Need to update Status to WIP for ComplaintID :123
How to do ?
Hey Gaurav
Try something like this:
var collection = <mymodel>.getProperty("/CompliantCollection");
for (var i = 0; i < collection.length; i++) {
if (collection[i].ComplaintId== "123")
<mymodel>.setProperty("/CompliantCollection/" + i + "/Status", "WIP");
};
Hope this help
Antonette 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gaurav,
I am trying to understand your use case here. You might probably have complainCollection items listed as a list or table control in your view.
The change that you are talking about in the status will be happening from the view via an editable input control or edit button. This is one common use case. If this is your scenario too, you can get the binding element (on what item the edit event occurs) in your controller using event listeners and you can directly set the value there.
But, if you want to trigger and set the change only in controller - I mean without the change being triggered from view (Not a common scenario though) , you would have to search the array for the right object (Object with complaint ID=123) before setting STATUS=WIP. Which search algorithm to use is upto you.
If this doesn't help, Please share your view and controller code so we can try solving it better.
Thanks,
Murali L
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.