PDA

View Full Version : Grid removing record.



joao_candido
9 Jun 2010, 10:24 AM
Ive got the follow code:



storeVideos = new Ext.data.JsonStore({
// store configs
autoLoad: true,
autoDestroy: true,
autoSave: true,
root: "records",
proxy: new Ext.data.HttpProxy({
method: "POST",
url: "getVideos.php",
api: {
update: "updVideo.php",
destroy: "delVideo.php"
}
}),
writer: new Ext.data.JsonWriter({
encode: true,
writeAllFields: true // write all fields, not just those that changed
}),
idProperty: "videos_id",
fields: [
{name: "videos_id", type: "int", mapping: "videos_id"},
{name: "videos_arquivo", type: "string", mapping: "videos_arquivo"},
{name: "videos_apelido", type: "string", mapping: "videos_apelido"},
{name: "videos_status", type: "boolean", mapping: "videos_status"},
{name: "videos_data", type: "date", mapping: "videos_data", dateFormat: "Y-m-d H:i:s"},
{name: "videos_segmento", type: "string", mapping: "videos_segmento"},
{name: "videos_sequencia", type: "int", mapping: "videos_sequencia"}
],
sortInfo: {
field: "videos_sequencia",
direction: "ASC"
},
baseParams: {
"segmento": Ext.get("combo_segmentos").getValue()
}
});

action = new Ext.ux.grid.RowActions({
header: "Excluir",
keepSelection: true,
autoWidth: false,
width: 50,
actions: [
{
iconCls: "icon-cross",
tooltip: "Excluir"
}
],
listeners: {
action: function(sGrid, record, action, row, col) {
sGrid.getStore().removeAt(row);
}
}
});

gridVideos = new Ext.grid.EditorGridPanel({
fieldLabel: "Videos",
store: storeVideos,
renderTo: "grid_videos",
enableDragDrop: true,
ddGroup : "mygrid-dd",
ddText: "Arraste para mudar a ordem.",
sm: new Ext.grid.RowSelectionModel({
singleSelect: true
}),
cm: new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer({width: 20}),
{
header: "Video",
sortable: false,
dataIndex: "videos_apelido",
editor: new Ext.form.TextField({})
},
{
header: "Data",
sortable: false,
dataIndex: "videos_data",
renderer: function(value, metaData, record, rowIndex, colIndex, store) {
return value.format("d/m/Y");
}
},
{header: "Segmento", sortable: false, dataIndex: "videos_segmento"},
{
header: "Status",
sortable: false,
dataIndex: "videos_status",
editable: true,
editor: combo,
renderer: Ext.util.Format.comboRenderer(combo)
},
action
]),
height: 160,
width: 540,
forceLayout: true,
plugins: [action],
view: new Ext.grid.GridView({
forceFit: true,
autoFill: true,
emptyText: "Nenhum video encontrado!"
})
});


My problem is when I click on "remove" acttion the record get removed from the database but it gets an error as follow.

this.getRow(row) is undefined
http://128.1.1.52/aol_conseg/admin/includes/extjs/ext-all-debug.js
Line 60813

Thanks in advance.

darthwes
9 Jun 2010, 2:34 PM
Whoa. Why? When you click on "remove" acttion? There's nothing to click when I put your code in a browser and fix it up. Why use this ux? Is it still being updated? Is this for 3.2.1? Where's the button to click? What code does it run? If you've removed the row already why fire another remove on an invalid index? Are you sure row is defined? Why not just remove the acttion altogether then?