Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DynamicForm in Window

    Hello all, i have this code:
    Code:
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.user.client.rpc.AsyncCallback;
    import com.google.gwt.user.client.ui.Grid;
    import com.google.gwt.user.client.ui.Label;
    import com.google.gwt.user.client.ui.TextBox;
    import com.smartgwt.client.util.BooleanCallback;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.ButtonItem;
    import com.smartgwt.client.widgets.form.fields.HeaderItem;
    import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
    import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.ListGridRecord;
    
    import PartesAsistService;
    import  PartesAsistServiceAsync;
    
    public class AgregarPartesConceptoLiquidacionDietas extends DynamicForm {
    	
    	@SuppressWarnings("unchecked")
    	public AgregarPartesConceptoLiquidacionDietas(final String usuario, final String codContrato) {
    		DynamicForm dynamicFormButtonSalir = new DynamicForm();
    		DynamicForm dynamicFormButtonConfirmar = new DynamicForm();
    		DynamicForm dynamicFormButtonQuitar = new DynamicForm();
    		DynamicForm dynamicFormButtonBajar = new DynamicForm();
    		DynamicForm dynamicFormListGridPartes = new DynamicForm();
    		final HeaderItem headerItemTitulo             = new HeaderItem();
    		final ListGrid listGridPartes                 = new ListGrid();
    		final ListGrid listGridPartesSeleccionados    = new ListGrid();
    		TextBox textboxHorasExtrasDesp                = new TextBox();
    		TextBox textboxHorasExtrasTrabajo             = new TextBox();
    		TextBox textboxDietas                         = new TextBox();
    		TextBox textboxKilometros                     = new TextBox();
    		TextBox textboxDietasLocales                  = new TextBox();
    		Label labelHDesplazamiento                    = new Label("Horas Extras Desplaz.");
    		Label labelHTrabajo                           = new Label("Horas Extras Trabajo");
    		Label labelDietas                             = new Label("Dietas");
    		Label labelDietasLocales                      = new Label("Dietas (Locales)");
    		Label labelKilometros                         = new Label("Kilómetros");
    		final ButtonItem buttonBajar                  = new ButtonItem("Bajar&#32Parte");
    		final ButtonItem buttonSubir                  = new ButtonItem("Quitar&#32Parte");
    		final ButtonItem buttonAceptar                = new ButtonItem("Confirmar");
    		final ButtonItem buttonSalir                  = new ButtonItem("Salir");
    		ListGridField listGridFieldCantidadEjecutada  = new ListGridField("cantidadEjecutada", "Cantidad&#32Ejecutada");
    		ListGridField listGridFieldFecha              = new ListGridField("fecha", "Fecha");
    		ListGridField listGridFieldIdParte            = new ListGridField("id_parte", "Id&#32Parte");
    		ListGridField listGridFieldNumero             = new ListGridField("numero", "N&#250mero");
    		ListGridField listGridFieldDescparte          = new ListGridField("desc_parte", "Descripci&#243n");
    		ListGridField listGridFieldKm                 = new ListGridField("km", "Km");
    		ListGridField listGridFieldDietas             = new ListGridField("dietas", "Dietas");
    		ListGridField listGridFieldHd                 = new ListGridField("hd", "H.&#32Desplaza.");
    		Grid gridCamposConcepto                       = new Grid(3,4);
    		final PartesAsistServiceAsync servicioPartes = (PartesAsistServiceAsync) GWT.create(PartesAsistService.class);
    		final AsyncCallback callbackPartesAsist = new AsyncCallback() {
    	        public void onSuccess(Object result) {
    	        	List<Map> respuesta = (List<Map>) result;
        			if(respuesta != null && respuesta.size() > 0){
            			ListGridRecord[] datos = new ListGridRecord[respuesta.size()];
            			Map item = null;
            			for(int i = 0; i < respuesta.size(); i++){
            				datos[i] = new ListGridRecord();
            				item =  new HashMap();
            				item = respuesta.get(i);
            				Iterator it = item.entrySet().iterator();
            				while (it.hasNext()) { 
            					Map.Entry e = (Map.Entry)it.next(); 
            					datos[i].setAttribute(String.valueOf(e.getKey()), e.getValue());
            				}
            			}
            			listGridPartes.setData(datos);
        			} else {
        	            ListGridRecord[] datos = new ListGridRecord[0];
        	            listGridPartes.setData(datos);
        			}
    	        }
    	        public void onFailure(Throwable caught){
    	        	SC.say("Fallo en la respuesta del servidor: " + caught.getMessage());
    	        }
    	    };
    	    servicioPartes.consultarPartes( callbackPartesAsist);
    		// Se configuran los componentes
    		headerItemTitulo.setTop(10);
    		gridCamposConcepto.getElement().setAttribute("style", "margin-top: 325px !important;");
    		listGridPartes.setWidth("430px");
    		listGridPartes.setHeight(150);
    		dynamicFormListGridPartes.setTop(45);
    		dynamicFormListGridPartes.setLeft(10);
    		listGridPartesSeleccionados.setTop(210);
    		listGridPartesSeleccionados.setWidth("430px");
    		listGridPartesSeleccionados.setHeight(100);
    		listGridPartesSeleccionados.setLeft(10);
    		dynamicFormButtonConfirmar.setLeft(320);
    		dynamicFormButtonConfirmar.setTop(420);
    		dynamicFormButtonSalir.setLeft(480);
    		dynamicFormButtonSalir.setTop(420);
    		dynamicFormButtonBajar.setLeft(450);
    		dynamicFormButtonBajar.setTop(130);
    		dynamicFormButtonQuitar.setLeft(450);
    		dynamicFormButtonQuitar.setTop(250);
    		listGridPartes.setCanResizeFields(true);
    		headerItemTitulo.setValue("Seleccione los partes que desee");
    		// Se añaden los componentes correspondientes al grid
    		listGridPartes.setFields(listGridFieldFecha,listGridFieldIdParte,listGridFieldNumero,listGridFieldDescparte,listGridFieldHd,listGridFieldKm,listGridFieldCantidadEjecutada,listGridFieldDietas);
    		gridCamposConcepto.setWidget(0, 0, labelHDesplazamiento);
    		gridCamposConcepto.setWidget(0, 1, textboxHorasExtrasDesp);
    		gridCamposConcepto.setWidget(0, 2, labelHTrabajo);
    		gridCamposConcepto.setWidget(0, 3, textboxHorasExtrasTrabajo);
    		gridCamposConcepto.setWidget(1, 0, labelKilometros);
    		gridCamposConcepto.setWidget(1, 1, textboxKilometros);
    		gridCamposConcepto.setWidget(1, 2, labelDietas);
    		gridCamposConcepto.setWidget(1, 3, textboxDietas);
    		gridCamposConcepto.setWidget(2, 0, labelDietasLocales);
    		gridCamposConcepto.setWidget(2, 1, textboxDietasLocales);
    		dynamicFormButtonSalir.setFields(buttonSalir);
    		dynamicFormButtonConfirmar.setFields(buttonAceptar);
    		dynamicFormButtonQuitar.setFields(buttonSubir);
    		dynamicFormButtonBajar.setFields(buttonBajar);
    		dynamicFormListGridPartes.addChild(listGridPartes);
    		// Se añaden los componentes a la pantalla
    		setFields(headerItemTitulo);
    		addChild(dynamicFormListGridPartes);
    		addChild(dynamicFormButtonBajar);
    		addChild(listGridPartesSeleccionados);
    		addChild(dynamicFormButtonQuitar);
    		addChild(gridCamposConcepto);
    		addChild(dynamicFormButtonConfirmar);
    		addChild(dynamicFormButtonSalir);
    	}
    }
    I put an object of this class in a window
    Code:
    button.addClickHandler(new ClickHandler() {
    			@Override
    			public void onClick(ClickEvent event) {
    				AgregarPartesConceptoLiquidacionDietas nuevoParte = new AgregarPartesConceptoLiquidacionDietas(usuario, (String)comboboxContrato.getDisplayValue());
    				final Window winModal = new Window();
    				winModal.setWidth(750);
    				winModal.setHeight(500); 
    			    	winModal.setTop(70);
    			    	winModal.setTitle("Seleccione el Parte de la Liquidación");  
    			    	winModal.centerInPage(); 
    			    	winModal.addItem(nuevoParte);
    				winModal.show();
    			}
    		});
    When I try to select a row of Listgrid I can not select the row. Can someone explain why?
    Thanks all, Regards Durin
    Last edited by Durin; 25 May 2010, 06:39.

    #2
    Post a standalone test case with smartgwt version. Can't run the code you posted.

    Comment


      #3
      Originally posted by svjard
      Post a standalone test case with smartgwt version. Can't run the code you posted.
      i have v2.1 SmartGwt and GWT SDK 2.0.3 in eclipse ganymede

      Comment


        #4
        Anyone know what is happening to me not being able to select a row of ListGrid when inserted into a Window component. If anyone knows it would make me the favor to answer?

        Regards Durin.

        Comment


          #5
          You can't expect all that code to be debugged by someone when it contains backend calls there is no way we can reproduce, hence the post a standalone test case. addChild() likely your issue though

          There should be no issue selecting a row inside a window. See example.

          Code:
          public void onModuleLoad() {  
                  
                 final Window win = new Window();
                 win.setHeight(400);
                 win.setWidth(400);
                 
                 ListGrid g = new ListGrid();
                 ListGridField f1 = new ListGridField("a", "A");
                 g.setFields(f1);
                 ListGridRecord r = new ListGridRecord();
                 r.setAttribute("a", "Value1");
                 g.addData(r);
                 
                 win.addItem(g);
                 win.setVisible(false);
                 
                 IButton b = new IButton("click me");
                 b.addClickHandler(new ClickHandler() {
          			@Override
          			public void onClick(ClickEvent event) {
          				win.show();
          			}
                 });
                 
                 b.draw();
              }

          Comment


            #6
            It is true, you can select a record from a component listgrid a window, but then what am I doing wrong is the burden of data in the listgrid, or do in a certain volume of data is no longer able to select data?

            Is it different when when working with a single record to when working with more records than one?

            I tested with 13 records and has not given me problems, I have to be within a DynamicForm as I've ridden my class and I have not had problems, I have added another row to the list grid and has not given me trouble. I guess the problem will be in the way I'm loading the data.

            I tried also to put the data I'm loading in my class, and the only thing I did different from my application to load the data is the following, put before the setFields data load () of listgrid and thus I work also select the data.

            But this is transferred to my class and I do not work. I will try removing all other components that has the screen to see if you work, you might place the other components to allow me to select, since a panel may be superimposed on the listgrid and do not let me select it for that.
            AND PREMIER, removed all objects on the screen and had a panel for some reason was not superimposing my leaving ListGrid select. Mysteries of programming

            I hope this serves someone in the future ...

            Thanks for the Help Svjard.
            Regards Durin.

            Originally posted by svjard
            You can't expect all that code to be debugged by someone when it contains backend calls there is no way we can reproduce, hence the post a standalone test case. addChild() likely your issue though

            There should be no issue selecting a row inside a window. See example.

            Code:
            public void onModuleLoad() {  
                    
                   final Window win = new Window();
                   win.setHeight(400);
                   win.setWidth(400);
                   
                   ListGrid g = new ListGrid();
                   ListGridField f1 = new ListGridField("a", "A");
                   g.setFields(f1);
                   ListGridRecord r = new ListGridRecord();
                   r.setAttribute("a", "Value1");
                   g.addData(r);
                   
                   win.addItem(g);
                   win.setVisible(false);
                   
                   IButton b = new IButton("click me");
                   b.addClickHandler(new ClickHandler() {
            			@Override
            			public void onClick(ClickEvent event) {
            				win.show();
            			}
                   });
                   
                   b.draw();
                }

            Comment


              #7
              The problem is this object, more specifically the line that declares the separation with the upper border:

              Code:
               
              gridCamposConcepto.getElement().setAttribute("style", "margin-top: 325px !important;");
              If you put the grid in a DynamicForm, and the DynamicForm and the DynamicForm tells you where it must be positioned relative to the margin you have the problem solved. This is because the grid create a table to be inserted. When you tell a margin at the top creates a panel that separates from the top. As I added the ListGrid before the Grid and the panel overlapped I created for the Grid can not select any row of the ListGrid.

              Code:
              public AgregarPartesConceptoLiquidacionDietas(final String usuario, final String codContrato) {
              		DynamicForm dynamicFormButtonSalir = new DynamicForm();
              		DynamicForm dynamicFormButtonConfirmar = new DynamicForm();
              		DynamicForm dynamicFormButtonQuitar = new DynamicForm();
              		DynamicForm dynamicFormButtonBajar = new DynamicForm();
              		DynamicForm dynamicFormListGridPartes = new DynamicForm();
                              DynamicForm dynamicFormGridDatos = new DynamicForm();
              		final HeaderItem headerItemTitulo             = new HeaderItem();
              		final ListGrid listGridPartes                 = new ListGrid();
              		final ListGrid listGridPartesSeleccionados    = new ListGrid();
              		TextBox textboxHorasExtrasDesp                = new TextBox();
              		TextBox textboxHorasExtrasTrabajo             = new TextBox();
              		TextBox textboxDietas                         = new TextBox();
              		TextBox textboxKilometros                     = new TextBox();
              		TextBox textboxDietasLocales                  = new TextBox();
              		Label labelHDesplazamiento                    = new Label("Horas Extras Desplaz.");
              		Label labelHTrabajo                           = new Label("Horas Extras Trabajo");
              		Label labelDietas                             = new Label("Dietas");
              		Label labelDietasLocales                      = new Label("Dietas (Locales)");
              		Label labelKilometros                         = new Label("Kilómetros");
              		final ButtonItem buttonBajar                  = new ButtonItem("Bajar&#32Parte");
              		final ButtonItem buttonSubir                  = new ButtonItem("Quitar&#32Parte");
              		final ButtonItem buttonAceptar                = new ButtonItem("Confirmar");
              		final ButtonItem buttonSalir                  = new ButtonItem("Salir");
              		ListGridField listGridFieldCantidadEjecutada  = new ListGridField("cantidadEjecutada", "Cantidad&#32Ejecutada");
              		ListGridField listGridFieldFecha              = new ListGridField("fecha", "Fecha");
              		ListGridField listGridFieldIdParte            = new ListGridField("id_parte", "Id&#32Parte");
              		ListGridField listGridFieldNumero             = new ListGridField("numero", "N&#250mero");
              		ListGridField listGridFieldDescparte          = new ListGridField("desc_parte", "Descripci&#243n");
              		ListGridField listGridFieldKm                 = new ListGridField("km", "Km");
              		ListGridField listGridFieldDietas             = new ListGridField("dietas", "Dietas");
              		ListGridField listGridFieldHd                 = new ListGridField("hd", "H.&#32Desplaza.");
              		Grid gridCamposConcepto                       = new Grid(3,4);
              		// Se configuran los componentes
              		headerItemTitulo.setTop(10);
                              dynamicFormGridDatos.setTop(325);
              		listGridPartes.setWidth("430px");
              		listGridPartes.setHeight(150);
              		dynamicFormListGridPartes.setTop(45);
              		dynamicFormListGridPartes.setLeft(10);
              		listGridPartesSeleccionados.setTop(210);
              		listGridPartesSeleccionados.setWidth("430px");
              		listGridPartesSeleccionados.setHeight(100);
              		listGridPartesSeleccionados.setLeft(10);
              		dynamicFormButtonConfirmar.setLeft(320);
              		dynamicFormButtonConfirmar.setTop(420);
              		dynamicFormButtonSalir.setLeft(480);
              		dynamicFormButtonSalir.setTop(420);
              		dynamicFormButtonBajar.setLeft(450);
              		dynamicFormButtonBajar.setTop(130);
              		dynamicFormButtonQuitar.setLeft(450);
              		dynamicFormButtonQuitar.setTop(250);
              		listGridPartes.setCanResizeFields(true);
              		headerItemTitulo.setValue("Seleccione los partes que desee");
              		// Se añaden los componentes correspondientes al grid
              		listGridPartes.setFields(listGridFieldFecha,listGridFieldIdParte,listGridFieldNumero,listGridFieldDescparte,listGridFieldHd,listGridFieldKm,listGridFieldCantidadEjecutada,listGridFieldDietas);
              		gridCamposConcepto.setWidget(0, 0, labelHDesplazamiento);
              		gridCamposConcepto.setWidget(0, 1, textboxHorasExtrasDesp);
              		gridCamposConcepto.setWidget(0, 2, labelHTrabajo);
              		gridCamposConcepto.setWidget(0, 3, textboxHorasExtrasTrabajo);
              		gridCamposConcepto.setWidget(1, 0, labelKilometros);
              		gridCamposConcepto.setWidget(1, 1, textboxKilometros);
              		gridCamposConcepto.setWidget(1, 2, labelDietas);
              		gridCamposConcepto.setWidget(1, 3, textboxDietas);
              		gridCamposConcepto.setWidget(2, 0, labelDietasLocales);
              		gridCamposConcepto.setWidget(2, 1, textboxDietasLocales);
              		dynamicFormButtonSalir.setFields(buttonSalir);
              		dynamicFormButtonConfirmar.setFields(buttonAceptar);
              		dynamicFormButtonQuitar.setFields(buttonSubir);
              		dynamicFormButtonBajar.setFields(buttonBajar);
              		dynamicFormListGridPartes.addChild(listGridPartes);
              		// Se añaden los componentes a la pantalla
              		setFields(headerItemTitulo);
              		addChild(dynamicFormListGridPartes);
              		addChild(dynamicFormButtonBajar);
              		addChild(listGridPartesSeleccionados);
              		addChild(dynamicFormButtonQuitar);
              		addChild(gridCamposConcepto);
              		addChild(dynamicFormButtonConfirmar);
              		addChild(dynamicFormButtonSalir);
              	}

              Comment

              Working...
              X