Friday, 19 July 2013

Add Hyper Link to a jTable Record

Normal jTable Records











jTable Records with Hyperlink













Coding...


jTableColumnName: {
                        title: 'Column Name',
                        width: '4%',
                        display: function (data) {
                            if (data.record.SomeOtherColumn != null) {
                                return $('<a href="/Pages/Project.aspx?ColumnId=' +
                                                  data.record.HjTableColumnNameIdentity + '">' +
                                                   data.record.jTableColumnName+ '</a>');
                            }
                            else {
                                return data.record.jTableColumnName
                            }
                        }
                    },


In the above image, some record only having hyperlink. if we need hyperlink for all the records, we can remove the "if-else" condition. If we are going to specify a condition, that should be in the jtable container.
for example,
Student table containing student name, the examination pass/fail informaion.
The student name, who passed the examination, having the hyperlink. others students names are without hyperlink. so pass/fail information should be in the jtable container.

Hyperlink for all the records




jTableColumnName: {
                        title: 'Column Name',
                        width: '4%',
                        display: function (data) {
                                   return $('<a href="/Pages/Project.aspx?ColumnId=' +
                                                  data.record.HjTableColumnNameIdentity + '">' +
                                                  data.record.jTableColumnName+ '</a>');                          
                        }
                    },

No comments:

Post a Comment