Link column editing

QuestionsLink column editing
Glenn asked 9 years ago

Hi Abu,
My database has links stored without www or http:// in front of them.
The below line gets the hyperlink to work.
$acol["default"] = "<a href='http://{url}' target='_blank'>{url}</a>";
Problem is when I edit or save the record it saves the record with all the extra's in it. Also, in an event I need to access the raw url but once again {$data["params"]["url"]} has all the extra's too.
Also, if I turn the edit for that column when I go into the form that field will not show.

Suggestions?
Thanks
Glenn

2 Answers
Abu Ghufran answered 9 years ago

Remove $col["link"], $col["linkoptions"] and $col["default"]. Use plain formatter:

$col["formatter"] = "function(cellval,options,rowdata){ return '<a target="_blank" href="http://'+cellval+'">'+cellval+'</a>&#039;; }";
$col["unformat"] = "function(cellval,options,cell){ return $('a', cell).attr('href').replace('http://&#039;,''); }";

This will make it raw text when edited and link when displaying.

Glenn answered 9 years ago

Thanks Abu,

Works perfect, and a very elegant solution.

Regards,
Glenn

Your Answer

17 + 16 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?