PDA

View Full Version : delete entry from store on a card layout detail page



timomueller
29 Apr 2013, 9:22 PM
Hi there,

I am using a card layout to represent a list view. When clicking on an item using itemDisclosureButton the detail record will be displayed.

On that side I would like to offer two buttons which I already have marked with actions:

{
xtype: "button",
ui: "confirm",
text: "Save changes",
action:'saveChanges',
},
{
xtype: "button",
ui: "action",
text: "Delete entry",
action:'deleteEntry',
}

In my controller class I implemented references and listen to the tap event:

refs: {
deleteButton: 'button[action=deleteEntry]',
saveButton: 'button[action=saveChanges]'
},

control: {
deleteButton: {
tap:'deleteRecord'
},
saveButton: {
tap:'saveChanges'
}
}

I have the following questions:
1. How can I pass the record id on the detail page to my function in the controller class?
2. How can I automatically go back to the card layout list view page instead of clicking the back button?


Thanks in advance for your help!
Timo

vadimv
29 Apr 2013, 11:10 PM
1. Is not clear how you display the record but if record's details are shown in a form, then to get record in deleteRecord method is very easy, should be sth like:


deleteRecord': function(button) {
var record = button.up('itemsdetailsform_selector').getRecord();


If is not a form, then the approach is the same, just use button.up(selector) to go to the parent view which has the record saved somehow(trough a reference within the view, or other way)

2. Get the view with the card layout, then use view.setActiveItem('xtype_or_index') or view.animateActiveItem('xtype_or_index', animationCfg)

Look trough sencha examples and docs and you will find almost any answer you need, including these ones