Topic: Are hyperlink column types possible in webgrid?

Hi Dmitry, It's been a while since I've posted, but I have been following the progress and discussions.
Anyway, I've been experimenting a bit with your new web grid option and have created a simple table online for my personal use.  It is working as expected so far, so all good there; however, I wanted to find out if it would be possible to add a new hyper-link type so that links to web pages can be stored such that they can just be clicked on to open a new tab or window to the linked location?  Cheers, Dennis.

Dennis

Re: Are hyperlink column types possible in webgrid?

Hello,


You can directly edit file index.html

Example you have field with name  "link"


1. Open file index.html in any text editor


2. Find this code

                                link: {
                                    title: 'Link',
                                    create: true,
                                    edit: true,
                                    list: true,
                                    width: '20%'},

3. Change it like this

                                link: {
                                    title: 'Link',
                                    create: true,
                                    edit: true,
                                    list: true,
                                    width: '20%',
                                    display: 
                                        function (data) {
                                            return '<a href=\"http://'+data.record.link+'\">' + data.record.link + '</a>'; 
                                        }},
Dmitry.

Re: Are hyperlink column types possible in webgrid?

It's better that I was able to get, but doesn't really work.

the display shows up as "undefined" in blue and underlined like a hyperlink, but the link itself is "http://undefined/" - it doesn't seem to pick up and display my stored link properly (which already has the http:// part included).
I tried changing it to be:

display: function (data) {return '<a href=\"'+data.record.link+'\">' + data.record.link + '</a>';}},

and similar as well as l trying with "data.value", "data.record.value" and "data" instead of "data.record.link", but no luck with any of these combinations.
I even tried to edit one of my links to remove the leading "http://" text, but that also didn't work...
Any other suggestions?

Dennis

Re: Are hyperlink column types possible in webgrid?

Please attach your index.html file.

Dmitry.

5 (edited by mr_d 2016-08-02 03:46:33)

Re: Are hyperlink column types possible in webgrid?

Here it is (attached) without your new "display" field attribute.

Post's attachments

Attachment icon index.html.txt 2.38 kb, 478 downloads since 2016-08-02 

Dennis

Re: Are hyperlink column types possible in webgrid?

mr_d wrote:

Here it is (attached) without your new "display" field attribute.

data.record.link

instead word "link" you should write the fieldname ('Currently At Link' in your case), but I think this script is not support spaces in the field names. You should remove all spaces from field names of your database.

Dmitry.