Announcement

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

  • Problem with LinkItem (does not work as expected, no textbox when enabled)

    Hi Isomorphic,

    please see this modified BuiltInDS.java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.Criteria;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.Record;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.FormItemValueFormatter;
    import com.smartgwt.client.widgets.form.fields.FormItem;
    import com.smartgwt.client.widgets.form.fields.LinkItem;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
    	private DynamicForm boundForm;
    	private IButton toogleBtn;
    
    	public void onModuleLoad() {
    		KeyIdentifier debugKey = new KeyIdentifier();
    		debugKey.setCtrlKey(true);
    		debugKey.setKeyName("D");
    
    		Page.registerKey(debugKey, new PageKeyHandler() {
    			public void execute(String keyName) {
    				SC.showConsole();
    			}
    		});
    
    		VLayout vLayout = new VLayout(10);
    		DataSource ds = DataSource.get("animals");
    		boundForm = new DynamicForm();
    		boundForm.setDataSource(ds);
    
    		TextItem commonName = new TextItem("commonName");
    		MyLinkItem lifeSpan = new MyLinkItem("lifeSpan", Type.Telephone);
    		MyLinkItem status = new MyLinkItem("status", Type.Mail);
    
    		boundForm.setFields(commonName, lifeSpan, status);
    		boundForm.fetchData(new Criteria("scientificName", "Loxodonta africana"));
    
    		toogleBtn = new IButton("Toggle disabled");
    		toogleBtn.addClickHandler(new ClickHandler() {
    			public void onClick(ClickEvent event) {
    				boundForm.setDisabled(!boundForm.getDisabled());
    				boundForm.markForRedraw("toggled disabled");
    			}
    		});
    
    		vLayout.setMembers(boundForm, toogleBtn);
    		vLayout.draw();
    	}
    
    	public enum Type {
    		Mail("mailto:"),
    		Telephone("tel:"),
    		Skype("callto:");
    
    		private String protocol;
    
    		private Type(String protocol) {
    			this.protocol = protocol;
    		}
    
    		public String getProtocol() {
    			return this.protocol;
    		}
    	}
    
    	public class MyLinkItem extends LinkItem {
    
    		public MyLinkItem(String name, final Type type) {
    			super(name);
    
    			setValueFormatter(new FormItemValueFormatter() {
    				@Override
    				public String formatValue(Object value, Record record, DynamicForm form, FormItem item) {
    					if (value != null && value.toString().length() > 0)
    						return isDisabled() ? type.getProtocol() + value.toString() : value.toString();
    					return null;
    				}
    			});
    		}
    	}
    }
    Even when enabled, it does not show the TextItem-Box, but the link. This is also true for the showcase sample form_controls_various. This is contrary to what the Javadocs say.
    Please also note that in the sample, the text "LinkItem" is not aligned with the text "Click Me" (both in Enterprise and Simplicity skin).

    I'd like to achieve the following:
    • Link (<a> or javascript, <a> preferred) when disabled
    • Input (TextItem) when enabled
    • Link on click, but other text displayed (e.g. DB-entry: "name@domain.com", link to "mailto:name@domain.com" displayed text: "name@domain.com")

    As enhancement, if possible:
    • For design reasons (I have TextItems above and below) I'd like this better when disabled: A disabled TextItem with a clickable link inside, with different styles (enabled: normal text, disabled: underlined text)


    I think this could be solved the best with two new APIs (setLinkURLFormatter(LinkURLFormatter), setLinkTitleFormatter(LinkTitleFormatter)), or reusing setValueFormatter(FormItemValueFormatter) for one of those.
    I think it does not work with setLinkTitle(String) when using DataBound items.

    I'm using v9.1p_2014-07-22 in FF26 Dev Mode and the online client showcase (also v9.1p_2014-07-22).

    Best regards,
    Blama
    Last edited by Blama; 22nd Jul 2014, 04:24.

  • Blama
    replied
    Hi Isomorphic,

    using v11.1p_2018-05-22 this now looks good for me with the testcase from #16 (just added value for the 1st FormItem).

    Click image for larger version

Name:	IssueSolved.png
Views:	1
Size:	6.8 KB
ID:	253293

    I'm sure this will fix the issue in my application as well.

    Best regards
    Blama

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    with an added height:30, for the 2nd item it does look good now with today's build as well in 6.1p.

    Thank you & Best regards
    Blama

    Leave a comment:


  • Isomorphic
    replied
    Ok, this has been fixed now - the problem was that LinkItem specified height:null by default, but it should no longer do that, instead inheriting the height from TextItem - we didn't notice this in testing because we built an offline sample based on this test-case and an earlier one of yours, which happened to specify a global height of 30 for LinkItems.

    If you do the same in your most recent example, setting a global height for LinkItems, that will emulate the fix we just applied, and should behave as you expect - otherwise, you can test the fix from tomorrow's builds.

    Leave a comment:


  • Isomorphic
    replied
    Hmm, a quick test shows both problems fixed in 12.0+ but we do indeed still see the height issue in 11.1 - we'll take a look just now.
    Last edited by Isomorphic; 17th May 2018, 07:02.

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    I retested with v11.1p_2018-05-17 and the code from #16 and still do see a difference to #21. The text is now not over the icon, not the positioning is still not correct. Please see this screenshot:

    Click image for larger version

Name:	LinkItem positioning.png
Views:	1
Size:	5.3 KB
ID:	253231
    Best regards
    Blama

    Leave a comment:


  • Isomorphic
    replied
    These changes have just hit and you can test them out in builds dated May 17 and later.

    Leave a comment:


  • Isomorphic
    replied
    Yes, apologies - we'll try to make these changes today.

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    I just retested the sample from #16 with v11.1p_2018-05-14 and it still looks the same.

    Best regards
    Blama

    Leave a comment:


  • Isomorphic
    replied
    Yes, apologies for the delay - we'll be adding new code shortly to apply an outer table that enforces the textBoxHeight and a v-centered, l-offset link, which should deal with these two situations.

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    I just retested the sample from #16 with v11.1p_2018-04-27 and it still looks the same.
    Click image for larger version

Name:	LinkItem.png
Views:	1
Size:	8.6 KB
ID:	253022

    Best regards
    Blama

    Leave a comment:


  • Isomorphic
    replied
    Apologies for the delay - we'll get to this in the next few days and update here when it's fixed.

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    can you have a look at this one now as well?

    Thank you & Best regards
    Blama

    Leave a comment:


  • Isomorphic
    replied
    We do see this issue, but we won't be able to get to it until after the imminent 12.0 release - we'll update here when it's fixed.

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    can you have a look at the sample code from #16? It shows the issue I displayed before in #14 with a screenshot.

    Best regards
    Blama

    Leave a comment:

Working...
X