I have json data in the format below
I display the top level memebers in a grid
The grid is bound to a form wher I display the top level memebers
Inside there is a nested comments object
I display the comments data inside this object to the right of the form using an Xtemplate to run over the items. I have a version online at http://www.cramb.org.uk/extjs/
What I want to do is to allow the users to edit the form
I have this for the top level memebers and it displays back on to the grid afetr saving the data
What I also want to do is to add a new comment in the comment area of the textarea on the form
This would mean updating the same record and appending nested data to the comments object.
This would then update the store and then I want to refresh the comments to the right of the form to reflect the new data
See the appended data in red below
I need a steer on how I can achieve this as at the moment I cannot figure out how I can do this or where to start
Any help is much appreciated
Andy
Code:
"success": true,
rows:[{
"id": "1",
"dueDate": "01/03/2009",
"creationDate": "10/12/2008",
"period": "Q4 2008",
"type": "Sales",
"description": "Support the Vision tendering process",
"customer": "Callum Lindsay",
"performer": "Andy Cramb",
"community": "Vision",
"state": "Acknowledgment",
"lastAct": "Assert Complete",
"scope": "private",
"openClose": "open",
"comments": [{
"commentId": "1",
"person": "Andy Cramb",
"act": "New Promise",
"date": "16/12/2008 09:21",
"comment": "I aim to support the Vision tendering process"
},{
"commentId": "2",
"person": "Andy Cramb",
"act": "Comment",
"date": "17/12/2008 10:21",
"comment": "I aim to adopt several approaches"
},{
"commentId": "3",
"person": "Callum Lindsay",
"act": "Comment",
"date": "18/12/2008 11:21",
"comment": "I can support you here Andy"
},{ //potential new record after the textarea in the form has new text and the form is saved
"commentId": "4",
"person": "Callum Lindsay",
"act": "Comment",
"date": "18/12/2008 11:21",
"comment": "I can support you here Andy"
}]
}]
};
Code:
//existing record
var myData = {
"success": true,
rows:[{
"id": "1",
"dueDate": "01/03/2009",
"creationDate": "10/12/2008",
"period": "Q4 2008",
"type": "Sales",
"description": "Support the Vision tendering process",
"customer": "Callum Lindsay",
"performer": "Andy Cramb",
"community": "Vision",
"state": "Acknowledgment",
"lastAct": "Assert Complete",
"scope": "private",
"openClose": "open",
"comments": [{
"commentId": "1",
"person": "Andy Cramb",
"act": "New Promise",
"date": "16/12/2008 09:21",
"comment": "I aim to support the Vision tendering process"
},{
"commentId": "2",
"person": "Andy Cramb",
"act": "Comment",
"date": "17/12/2008 10:21",
"comment": "I aim to adopt several approaches"
},{
"commentId": "3",
"person": "Callum Lindsay",
"act": "Comment",
"date": "18/12/2008 11:21",
"comment": "I can support you here Andy"
}]
}]
};