31 de agosto de 2008

Ejemplo de Master Detail en WM4


En esta aplicacin muestro el uso de un maestro detalle usando solo liveVariables para normales aplicaciones CRUD y liveView para CRUD relacionales eso es todol...

este es mi codigo que tengo que añadir en "pagina Sales" ......
dojo.declare("Sales", wm.Page, {
start: function() {

},
liveForm1Success: function(inSender, inData) {
//this shows the detail panel and filter the detail datagrid for current sale
this.panel2.setValue("showing",true);
this.liveVariable2.update();
},
dataGrid1Selected: function(inSender, inIndex) {
//this shows the detail panel and filter the detail datagrid for current sale and go to layer for show all complete sale
this.panel2.setValue("showing",true);
this.liveVariable2.update();
this.gotoLayer2.update();
},
newSaleButtonClick: function(inSender, inEvent) {
//this hide the detail panel and prepar to insert a new master sale
this.editPanel1.beginDataInsert();
this.panel2.setValue("showing",false);
},
_end: 0
});

tambien uso un trigger para actualizar id_master actual en el detalle
CREATE OR REPLACE FUNCTION set_last_master_id()
RETURNS "trigger" AS
$BODY$declare
_id_master integer;
begin
_id_master=0;
select max(id_master) into _id_master from master_sales;
new.id_master=_id_master;
return new;
end;$BODY$
LANGUAGE 'plpgsql' VOLATILE;

--------------------------------------------------------------------
CREATE TRIGGER "beforeInsertSetLastMasterId"
BEFORE INSERT
ON detail_sales
FOR EACH ROW
EXECUTE PROCEDURE set_last_master_id();
---------------------------------------------------------------------

Note: las liveVariables no esta actualizando por defecto
Espero q pueda ayudarte :)
Fuentes:
http://dev.wavemaker.com/forums/files/MasterDetailProject.zip
http://dev.wavemaker.com/forums/files/master_detail_db.sql_.txt
http://dev.wavemaker.com/forums/files/master_detail_db.jpg

No hay comentarios:

Mis cosas

Powered By Blogger