PDA

View Full Version : Ext.ActionSheet delete listitem



ChillsNL
26 Apr 2011, 5:15 AM
Good day people,

After some reading about the kitchensink demo, I noticed that my application looks a kind of simular to the kitchensink example. As result of that, I've removed all the code and restart making the application.

The problem is as follow, I've made a list with dynamic loading. No problem getting some record data. After an item is tapped, an ActionSheet covers the the bottom of the application and shows 3 buttons. The first one deletes an item, second one doesn't work yet and the third removes the ActionSheet.

The plan of all of this, is when the user clicks on one of the items in the list, it saves that record and when pressed the first button(delete), it removes the item from the list.

The most of it is already programmed, but I can't save the record of the list and when clicking on the first button it doesn't deletes it cause I don't have that record.

Question:How do I save the firstName of the current record and make it delete from the list?

Here is my code:
/************************ Index.JS *************************
* Created on 14 - 03 - '11 | 15:43 by JR. *
* This is the main JavaScript file of FWM *
***********************************************************/
Ext.ns('FWM', 'GW');

//Start Setup
Ext.setup
({
tabletStartupScreen: 'resources/img/tablet_startup.png',
phoneStartupScreen: 'resources/img/phone_startup.png',
icon: 'resources/img/icon.png',
glossOnIcon: false,
//Start onReady
onReady: function()
{
//Start Panel
this.panel = new Ext.Panel
({
fullscreen : true,
dockedItems :
[{
dock : 'top',
xtype : 'toolbar',
title : 'FWMobile',
items :
[{
ui : 'rounded',
text : 'Test Button',
handler : ''
}]
}],
html : 'FreightWare Mobile 1.000.001',
cls : 'launchscreen'
});
//End Panel

//Start Model
Ext.regModel('Contact',
{
fields:
[{
name: 'firstName',
type: 'string'
},{
name: 'lastName',
type: 'string'
}]
});
//End Model
//Start ActionSheet

//End ActionSheet
//Start ListStore
GW.ListStore = new Ext.data.Store
({
model: 'Contact',
proxy:
{
type : 'ajax',
url : 'GWService.svc/GWEndPoint/getPersons',
reader :
{
type: 'json',
root: 'getPersonsResult'
},
actionMethods:
{
create : 'POST',
read : 'POST',
update : 'POST',
destroy : 'POST'
}
},
autoLoad: true
});
//End ListStore
//Start TabPanel
GW.List = new Ext.TabPanel
({
fullscreen : true,
items :
[{
title : 'MyLists',
layout :
{
type : 'vbox',
width : '300',
align : 'center',
pack : 'center'
},
cls : '',
items :
[{
iconCls : 'download',
width : 300,
height : 500,
xtype : 'list',
store : GW.ListStore,
itemTpl : '<div class="contact"><strong>{firstName}</strong> {lastName}</div>',
onItemDisclosure : function(record)
{
GW.CurrentItem = record.get('firstName') + ' ' + record.get('lastName');
Ext.Msg.alert('Heey',GW.CurrentItem,Ext.emptyFn);
GW.actionSheet.show();
}
}]
}]
});
//End TabPanel
GW.actionSheet = new Ext.ActionSheet
({
items:
[{
text : 'Delete draft',
ui : 'decline',
listeners :
{
click:
{
element : 'el', //bind to the underlying el property on the panel
fn : function(record)
{
Ext.Msg.alert('Hoi',record.get('firstName'),Ext.emptyFn);
}
}
}
},
{
text: 'Save draft'
},
{
text : 'Cancel',
ui : 'confirm',
listeners :
{
click:
{
element : 'el', //bind to the underlying el property on the panel
fn : function()
{
GW.actionSheet.hide();
}
}
}
}]
});
}
//End onReady
});
//End Setup
Ext.ns('GW', 'GW.Data');

ChillsNL
26 Apr 2011, 11:18 PM
Can anyone help me? It's not that it's really important, but it has an high priority. Currently fixen the list, than on click, it saves the records name, it creates an new list and makes an backbutton wich, on press, reloads the older list.