Hi Isomorphic,
please see this modified BuiltInDS.java:
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:
As enhancement, if possible:
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
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; } }); } } }
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
Comment