jQuery UI Widgets › Forums › Grid › Filter for a hyperlink column
This topic contains 3 replies, has 2 voices, and was last updated by Dimitar 10 years ago.
-
Author
-
I need to filter (using the filter row option) on a column that has been rendered via a cellsrenderer function into a hyperlink. The hyperlink ends up getting dynamically created based on row data something like this: ‘‘ + name + ‘‘. Here is the code I use to create the hyperlink:
renderLink = function (row, column, value) { var name = arguments[5].Name; var anchor = '<a href="' + value + '">' + name + '</a>'; return anchor; }
The display of the data in the column is the name portion of the anchor I show above. The name displays as the hyperlink, but the actual data in the row is the link itself – which does not contain the name data. The user will be typing in the name value to filter the rows…but obviously, nothing is returned because the rendered hyperlink is something like…”appname/blah.aspx?basket=12&somethingelse=0″
I’ve tried intercepting the filter event, but I can’t seem to override the datafield value being used for the filter. Also, if I attempt to remove and replace the existing filter, the filter event fires again and there are errors related to undefined values for the getfilterinformation method the second time into the event.
Is there any way I can work around this issue?
Hello Chazmanian,
Unfortunately, the only way to achieve this is through custom filtering.
Another suggestion is to “reverse” your logic – have the value as name of the hyperlink and the name as url.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Thanks for the quick response.
I’ll take another look at the custom filtering option. I was hoping that there was some way to intercept the filtering process and filter on a different datafield (the name rather than the hyperlink). I can’t really use the value part for display because that is a meaningless (to the user) hyperlink that references an ASPX page with two parameters.
Is there some way to intercept the normal filtering process? I have tried the filter event with no success. With custom filtering – I would still have to have a filter row at the top of the grid. Your example doesn’t really demonstrate that.
Hi Chazmanian,
1) What I mean was not that you change what is displayed, but store the name of the link as cell value and the url of the links in the arguments array. This way, your renderLink function would become:
renderLink = function(row, column, value) { var url = arguments[5].Name; var anchor = '<a href="' + url + '">' + value + '</a>'; return anchor; }
and you would be able to filter by the hyperlink name.
2) If you wish, you can implement a custom filter row (with custom filtering) in the grid’s toolbar.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.