Announcement

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

    only 2 of 6 buttons are enabled

    SmartGWT 2.2, all the modern browsers.

    I have a form with 3 rows.
    Each row has 1 statictextitem and 2 buttonitems.
    I show/draw the form (with disabled buttons), traverse through an array of records where I enable a row of buttons, if the conditions are right.

    If I try to enable all of the buttons, only the first row of buttons will be enabled. If I try to enable the 2nd or 3rd row of buttons, only the first row of buttons will be enabled.
    I tried redrawing the buttons/form, but no luck.

    Code:
    /* button creation code omitted */
    
    formDF.setFields(skipperAlertTextItem, skipperAlertOnButton, skipperAlertOffButton,
    			other1TextItem, other1OnButton, other1OffButton,
    			other2TextItem, other2OnButton, other2OffButton,
    			disabledSTItem);
    	
    	for (ListGridRecord record : listGrid.getRecords()) {
    		final String key = record.getAttributeAsString("Key");
    		
    		Common.getOutputSettings(key, new IHandleOutputSettings() {
    			public void updateFormWithData(Record[] records) {
    				if (records != null && records.length > 0) {
    					final String desc1 = records[0].getAsString("Description1");
    					final String desc2 = records[0].getAsString("Description2");
    					
    					if(desc1 == null || desc1.trim().isEmpty() || desc1.trim().equals("Disabled")) {
    						disabledKeys.add(key);
    						
    						disabledSTItem.setTitle("Disabled (" + disabledKeys.size() + ")");
    						disabledSTItem.redraw();
    					}
    					else if(desc1.trim().equals("Skipper alert")) {
    						skipperAlertKeys.add(key);
    						
    //									skipperAlertOnButton.setDisabled(false);
    //									skipperAlertOffButton.setDisabled(false);
    						skipperAlertTextItem.setTitle("Skipper alert (" + skipperAlertKeys.size() + "): ");
    						skipperAlertTextItem.redraw();
    					}
    					else {
    						other1Keys.add(key);
    						
    //									other1OnButton.setDisabled(false);
    //									other1OffButton.setDisabled(false);
    						other1TextItem.setTitle("Other 1 (" + other1Keys.size() + "): ");
    						other1TextItem.redraw();
    					}
    					
    					if(desc2 == null || desc2.trim().isEmpty() || desc2.trim().equals("Disabled")) {
    						disabledKeys.add(key);
    						
    						disabledSTItem.setTitle("Disabled (" + disabledKeys.size() + ")");
    						disabledSTItem.redraw();
    					}
    					else {
    						other2Keys.add(key);
    						
    //									other2OnButton.setDisabled(false); // WTF: karkoli enablam, se bo samo skipperAllertButtoni enablali, ostlai pa ostali disablani; report bug?
    //									other2OffButton.setDisabled(false);
    						other2TextItem.setTitle("Other 2 (" + other2Keys.size() + "): ");
    						other2TextItem.redraw();
    					}
    					
    					other2OnButton.setDisabled(false);
    					other2OffButton.setDisabled(false);
    					other1OnButton.setDisabled(false);
    					other1OffButton.setDisabled(false);
    					skipperAlertOnButton.setDisabled(false);
    					skipperAlertOffButton.setDisabled(false);
    				
    				}
    			}
    		});
    	}

    #2
    Once drawn use enable()/disable()

    Comment


      #3
      Unfortunately, the behaviour is the same.

      Comment


        #4
        Can you post the code your trying to use now, note also not possible to be sure all your doing is correct, so can you also just hard code an enable()/disable() call at some point and verify whether it works or not.
        Last edited by svjard; 29 Jun 2010, 08:19.

        Comment


          #5
          this is the updated excerpt:
          Code:
          formDF.setFields(skipperAlertTextItem, skipperAlertOnButton, skipperAlertOffButton,
          			other1TextItem, other1OnButton, other1OffButton,
          			other2TextItem, other2OnButton, other2OffButton,
          			disabledSTItem);
          	
          for (ListGridRecord record : listGrid.getRecords()) {
          	final String key = record.getAttributeAsString("Key");
          	
          	Common.getOutputSettings(key, new IHandleOutputSettings() {
          		public void updateFormWithData(Record[] records) {
          			if (records != null && records.length > 0) {
          				final String desc1 = records[0].getAsString("Description1");
          				final String desc2 = records[0].getAsString("Description2");
          				
          				if(desc1 == null || desc1.trim().isEmpty() || desc1.trim().equals("Disabled")) {
          					disabledKeys.add(key);
          					
          					disabledSTItem.setTitle("Disabled (" + disabledKeys.size() + ")");
          					disabledSTItem.redraw();
          				}
          				else if(desc1.trim().equals("Skipper alert")) {
          					skipperAlertKeys.add(key);
          					
          					skipperAlertOnButton.enable();
          					skipperAlertOffButton.enable();
          					skipperAlertTextItem.setTitle("Skipper alert (" + skipperAlertKeys.size() + "): ");
          					skipperAlertTextItem.redraw();
          				}
          				else {
          					other1Keys.add(key);
          					
          					other1OnButton.enable();
          					other1OffButton.enable();
          					other1TextItem.setTitle("Other 1 (" + other1Keys.size() + "): ");
          					other1TextItem.redraw();
          				}
          				
          				if(desc2 == null || desc2.trim().isEmpty() || desc2.trim().equals("Disabled")) {
          					disabledKeys.add(key);
          					
          					disabledSTItem.setTitle("Disabled (" + disabledKeys.size() + ")");
          					disabledSTItem.redraw();
          				}
          				else {
          					other2Keys.add(key);
          					
          					other2OnButton.enable();
          					other2OffButton.enable();
          					other2TextItem.setTitle("Other 2 (" + other2Keys.size() + "): ");
          					other2TextItem.redraw();
          				}
          			}
          		}
          	});
          }
          and here is the whole thing:
          http://pastebin.com/BKxz3FCM

          Comment


            #6
            Well not going to debug the whole app, but are you 100% sure things like skipperAlertOnButton.enable(); is really getting called? Here is a standalone where you can easily see the method of enable()/disable() works fine, there is something specific with your logic not those calls.
            Code:
            public void onModuleLoad() {
            	VLayout vLayout = new VLayout();
            	vLayout.setWidth100();
            	vLayout.setHeight100();
            	
            	final DynamicForm form = new DynamicForm();
            	form.setNumCols(6);
            	final StaticTextItem a1 = new StaticTextItem();
            	final ButtonItem b1 = new ButtonItem();
            	b1.setStartRow(false);
            	b1.setEndRow(false);
            	final ButtonItem c1 = new ButtonItem();
            	c1.setStartRow(false);
            	final StaticTextItem a2 = new StaticTextItem();
            	final ButtonItem b2 = new ButtonItem();
            	b2.setStartRow(false);
            	b2.setEndRow(false);
            	final ButtonItem c2 = new ButtonItem();
            	c2.setStartRow(false);
            	final StaticTextItem a3 = new StaticTextItem();
            	final ButtonItem b3 = new ButtonItem();
            	b3.setStartRow(false);
            	b3.setEndRow(false);
            	final ButtonItem c3 = new ButtonItem();
            	c3.setStartRow(false);
            	form.setItems(a1, b1, c1, a2, b2, c2, a3, b3, c3);
            	
            	IButton disableRow1 = new IButton("Disable Row 1");
            disableRow1.addClickHandler(new ClickHandler() {
            	@Override
            	public void onClick(ClickEvent event) {
            		for (int i = 0; i < form.getFields().length; i++)
            			form.getFields()[i].enable();
            		a1.disable();
            		b1.disable();
            		c1.disable();
            	}
            });
            IButton disableRow2 = new IButton("Disable Row 2");
            disableRow2.addClickHandler(new ClickHandler() {
            	@Override
            	public void onClick(ClickEvent event) {
            		for (int i = 0; i < form.getFields().length; i++)
            			form.getFields()[i].enable();
            		a2.disable();
            		b2.disable();
            		c2.disable();
            	}
            });
            IButton disableRow3 = new IButton("Disable Row 3");
            	disableRow3.addClickHandler(new ClickHandler() {
            		@Override
            		public void onClick(ClickEvent event) {
            			for (int i = 0; i < form.getFields().length; i++)
            				form.getFields()[i].enable();
            			a3.disable();
            			b3.disable();
            			c3.disable();
            		}
            	});
            	
            	vLayout.addMember(form);
            	vLayout.addMember(disableRow1);
            	vLayout.addMember(disableRow2);
            	vLayout.addMember(disableRow3);
            	vLayout.draw();
            }

            Comment


              #7
              All the enable() methods seems to execute (I've stepped through in debug mode).

              Okay, I'll try something different to achieve the same effect.

              Comment

              Working...
              X