PDA

View Full Version : getting the datastore id from EditorGridPanel



farout
18 Nov 2010, 11:00 AM
got a editorgridpanel and i need to get the 1st column of the row

my store



var employeeStore = new Ext.data.JsonStore({
url: 'view/employees.php',
baseParams: { xaction: 'rows' },
root: 'rows',
idProperty: 'employeeid',
fields: ['employeeid', 'employeename', 'department', 'position'],
writer: new Ext.data.JsonWriter()
//,autoSave: true
,batch: true
});


my editor grid config


var employeeGrid = new Ext.grid.EditorGridPanel({
id: 'employees-grid'
,title:'Employees'
,store: employeeStore
,columns: [
{ header: "ID", width: 30, dataIndex: 'employeeid', sortable: true, hidden:true },
{ id: 'employeename-id', header: "Employee Name", width: 180, dataIndex: 'employeename', sortable: true,
editor: new Ext.form.TextField({allowBlank: false, maxLength: 150})
},
{ header: "Department", width: 95, dataIndex: 'department', sortable: true, align: 'left',
editor: new Ext.form.ComboBox({store: departmentStore, displayField: 'department', valueField: 'departmentid', editable: false,
mode: 'remote', forceSelection: true, triggerAction: 'all', selectOnFocus: true, lazyRender:true,})
},
{ header: "Position", width: 95, dataIndex: 'position', sortable: true, align: 'left',
editor: new Ext.form.ComboBox({store: positionStore, displayField: 'position', valueField: 'positionid', editable: false,
mode: 'remote', forceSelection: true, triggerAction: 'all', selectOnFocus: true})
}]
,autoExpandColumn: 'employeename-id'
,tbar:[{
text: 'Delete'
,handler: function() {
var sm = Ext.getCmp("employees-grid").getSelectionModel();
if (!sm.hasSelection()){
Ext.Msg.show({
title: 'Warning!',
msg: "Please select a record!",
icon: Ext.Msg.WARNING,
buttons: Ext.Msg.OK
});
return;
}

var id = sm.getSelected().data.employeeid;

Ext.MessageBox.alert('Uh uh...', id); //getting error in firebug saying sm.getSelected is not a function

}
}]
,layout: 'fit'
,loadMask: true,
clicksToEdit:'2'
,bbar: new Ext.PagingToolbar({
pageSize: 20,
store: employeeStore,
displayInfo: true,
displayMsg: 'Displaying movies {0} - {1} of {2}',
emptyMsg: "No records found"
})
});
employeeStore.load();
employeeGrid.on('afteredit', saveEmployees);


heres the error ()


sm.getSelected is not a function
var id = sm.getSelected().data.employeeid;


how would i get the employeeid? is there another way to get it?

thanks in advance