Mostrando entradas con la etiqueta master detail. Mostrar todas las entradas
Mostrando entradas con la etiqueta master detail. Mostrar todas las entradas

5 de septiembre de 2008

Master Detail V2 en WM4



1)Importar la  base de datos "master_detai_db"
2)Crear liveViews para el master y el detail en LiveView panel
- masterView -> seleccionar todos los checkboxes y guardar
- detailView ->  seleccionar todos los  checkboxes y guardar
  
3)En el designer
- cambiar en layoutBox la propiedad "box" : de Top_to_Botton a Left_to_Right
- en el palette añadir 2 templates "SearchListDetail" y aplicar flex en los 2
4)Crear variables
 Crear 1 liveVariable para el master ->liveSource : masterView y quitarle el seleccionado a la propiedad autoUpdate
 Crear 1 liveVariable para el detail ->liveSource : detailView y quitarle el seleccionado a la propiedad autoUpdate
 Crear 1 variable para el actual master ->type : Master
5) Enlazar(Bind)..... master y detail con los widgets

Para el master:
   - Bind dataGrid1 con el liveVariable1 
- Bind liveVariable1 con el dataGrid1.selectedItem

Para el:
   - Bind dataGrid2 con el liveVariable2 
- Bind liveVariable2 con el dataGrid2.selectedItem

        Para el  actual_master:
- Bind variable1 -> dataSet -> idMaster con el liveForm1.dataOutput.idMaster


6) Filtrar el liveVariable2 para mostrar los datos del detail 
    - Bind detail -> master -> idMaster con el liveForm1.dataOutput.idMaster
    - En el liveForm2 -> event -> OnSuccess  -> liveVariable2
    - En el  dataGrid1 -> event -> OnSelected -> liveVariable2

7) Seleccionar el widget liveForm2 para poner el actual_master en el  related panel
- Seleccionar el widget masterSalesRelatedEditor1 y cambiar la propiedad "editingMode" : de lookup a readonly
   - Crear un evento en BeginInsert con javascript y colocar:
 liveForm2BeginInsert: function(inSender) {
    this.masterSalesRelatedEditor1.setDataSet(this.variable1);
 },

8) En la funcion inicial de la pagina poner: 
  start: function() { 
                      this.liveVariable1.update();  
                   }


Fuentes:

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

Mis cosas

Powered By Blogger