-
Notifications
You must be signed in to change notification settings - Fork 796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
for format type "link", allow seperate text from href #800
Comments
Hey @sellersj You are in luck, the link editor is getting an overhaul in next months release :) Cheers Oli |
Hey @sellersj you will be happy to hear i have just pushed some updates for the link formatter to the 3.4 branch, there are now a number of additional formatterParams you can pass with the link formatter to change the way it displays: Set label from another field in the table: {title:"Link", field:"url", formatter:"link", formatterParams:{labelField:"url_label"}}, Set label from another string or callback {title:"Link", field:"url", formatter:"link", formatterParams:{label:"Click Here"}},
{title:"Link", field:"url", formatter:"link", formatterParams:{label:function(cell){return "Click for " + cell.getData().title}}}, Set url from another field in the table: {title:"Link", field:"url_label", formatter:"link", formatterParams:{urlField:"url"}}, Set url from another string or callback {title:"Link", field:"url_label", formatter:"link", formatterParams:{url:"http://www.google.com"}},
{title:"Link", field:"url_label", formatter:"link", formatterParams:{url:function(cell){return "http://" + cell.getData().url}}}, These will be included in the 3.4 offical release in a couple of weeks time. Cheers Oli :) |
Tabulator version 3.4 has now been officially released! You can find details of the new release in the News Section Full documentation of all the new features can be found Here Cheers Oli :) |
This was great! Thanks for your hard work. |
Ideal, to be "plug and play", is a kind of URI template instead of {title:"Link1", field:"url_label1", link-template:"http://www.google.com"},
{title:"Link2", field:"url_label2", link-template:"http://{url}"},
{title:"Link3", field:"url_label3", link-template:"/otherPage/{cellName1}/{cellName2}"} Implementation: when a field specification have link-template, it must be pre-parsed, to expand into function procLinkTemplate(cell,s0){ // s0 is the link_template_input
const r = RegExp('\{([^\}]*)\}', 'g');
let s = '';
let a;
let idx=0
while ((a = r.exec(s0)) !== null) {
s += ( s0.substring(idx, r.lastIndex-a[0].length) + (cell.getData())[a[1]] )
idx = r.lastIndex
}
if ( idx<s0.length ) s+=s0.substring(idx,s0.length)
return s
} PS: need a new enhance-issue, suggesting "friendly link"? |
It would be nice if the "link" type allowed you to pass in optional formatterParams that you could override the default text or href data.
This would help for when you want the text to be shorter and readable, but the link is long and doesn't make sense to actually have in the table.
The text was updated successfully, but these errors were encountered: