Agradecería si alguien pudiera ayudarme...
Archivo JS:
- Código: Seleccionar todo
Ext.ns("com.quizzpot.tutorials");
com.quizzpot.tutorials.Crud = {
init : function() {
//CRUD
var proxy = new Ext.data.HttpProxy({
api: {
read : "serverside/getContacts.php",
create : "serverside/createContact.php",
update : "serverside/updateContact.php",
destroy : "serverside/destroyContact.php"
}
});
var rd_random_employee_data = new Ext.data.JsonReader({}, ['idprovincia', 'descprovincia']);
var ds_random_employee_data_active = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
// this json data contains only employees where active is 'true'
url: 'serverside/getProvincias.php'
}),
reader: rd_random_employee_data,
remoteSort: false
});
var random_employees_active = new Ext.form.ComboBox({
store: ds_random_employee_data_active,
valueField: 'idprovincia',
displayField: 'descprovincia',
mode: 'remote',
minChars : 0
});
var reader = new Ext.data.JsonReader({
totalProperty : 'total',
successProperty : 'success', //<--- el successproperty indica la propiedad que define si se ha insertado/actualizado o borrado con éxito
messageProperty : 'message',
idProperty : 'coddelegacion',
root : 'data' //<--- este es el nombre del parámetro que llega al servidor con el JSON modificado
},[
{name: 'descdelegacion', allowBlank: false},
{name: 'domiciliodelegacion', allowBlank: false},
{name: 'poblaciondelegacion', allowBlank: false},
{name: 'provinciadelegacion', allowBlank: false},
{name: 'emaildelegacion', allowBlank: false}
]);
var writer = new Ext.data.JsonWriter({
encode : true,
writeAllFields : true //<--- decide si se manda al servidor solamente los campos modificados o todos
});
this.storeGrid = new Ext.data.Store({
id : "id",
proxy : proxy,
reader : reader,
writer : writer,
autoSave : true //<--- hace las peticiones al servidor automáticamente
});
this.storeGrid.load();
var textFieldEmail = new Ext.form.TextField({vtype: "email",allowBlank: false}),
textField = new Ext.form.TextField({allowBlank: false}),
textField = new Ext.form.TextField({allowBlank: false}),
sm = new Ext.grid.CheckboxSelectionModel();
this.grid = new Ext.grid.EditorGridPanel({
store : this.storeGrid,
columns : [
sm,
{header:'Delegación', dataIndex:'descdelegacion',width:180,sortable: true, editor:textField},
{header:'E-mail', dataIndex:'emaildelegacion',sortable: true,width:180,editor:textFieldEmail},
{header:'Domicilio', dataIndex:'domiciliodelegacion',sortable: true,width:150, editor:textField},
{header:'Población', dataIndex:'poblaciondelegacion',sortable: true,width:150, editor:textField},
{header:'Provincia', dataIndex:'provinciadelegacion',sortable: true,width:150, editor:random_employees_active}
],
sm : sm,
border : false,
stripeRows : true,
bbar: new Ext.PagingToolbar
({
store : this.storeGrid,
displayMsg: 'Viendo {0} - {1} de {2} Delegaciones',
pageSize:10,
displayInfo:true
})
});
var win = new Ext.Window({
title : "eProject - Gestión Delegaciones",
layout : "fit",
tbar : [
{text:'Añadir Delegación', scope:this, handler:this.addContact,iconCls:'save-icon'},
{text:"Eliminar Selección", scope:this, handler:this.onDelete,iconCls:'delete-icon'},
{text:"Exportar", scope:this, handler:this.exportPDF,iconCls:'pdf-icon'},
{text:"Exportar", scope:this, handler:this.exportExcel,iconCls:'excel-icon'}
],
width : 800,
height : 300,
items : [this.grid]
});
win.show();
},
onDelete : function(){
var rows = this.grid.getSelectionModel().getSelections();
if(rows.length === 0){
return false;
}
this.storeGrid.remove(rows);
Ext.MessageBox.alert('eProject','Registro(s) Eliminado(s) Con Éxito');
},
addContact : function(){
var contact = new this.storeGrid.recordType({
delegacion : "",
domicilio : "",
poblacion : "",
email : ""
});
this.grid.stopEditing();
this.storeGrid.insert(0,contact);
this.grid.startEditing(0,1);
this.grid.getBottomToolbar().updateInfo();
},
exportPDF: function(){
alert("exportar a PDF");
},
exportExcel: function(){
alert("exportar a Excel");
}
}
Ext.onReady(com.quizzpot.tutorials.Crud.init,com.quizzpot.tutorials.Crud);
Archivo getProvincias.php
- Código: Seleccionar todo
<?php
$connection= mysql_connect("localhost","kszwsoso_ugespro","ugespro") or die("Connection Failed".mysql_error());
mysql_select_db("kszwsoso_gestorproyectos",$connection)or die("Error loading the DataBase".mysql_error());
$result= mysql_query("SELECT idprovincia,descprovincia FROM gestprovin001");
while($row= mysql_fetch_array($result))
{
array_push($data,array(
"idprovincia" => $row["idprovincia"],
"descprovincia" => $row["descprovincia"]
));
}
echo json_encode(
array(
"success" => true,
"data" => $data
));
Gracias de antemano!!!!

