This is a migrated thread and some comments may be shown as answers.

Problem sorting the Hyperlink COlumn in text

3 Answers 143 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Uttam Dhakal
Top achievements
Rank 1
Uttam Dhakal asked on 29 Oct 2012, 04:28 AM
I have creating a link in one of the gridcolumn.i have calcualted the link using some columns and some server side variables.
Now when i assign that value to the column i cannot sort and filter it as a string.
Is there a way i can use the Hyperlink Column which will have the String value while filtering and sorting.
So that i can have the links but when i filter and sort it it behaves as the string column only.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Oct 2012, 04:36 AM
Hi,

One suggestion is that you can use a GridHyperLinkColumn with the SortExpression value matching the DataTextField property of the column.
aspx:
<telerik:GridHyperLinkColumn DataTextField="Id" NavigateUrl="http://www.google.com" HeaderText="Id" SortExpression="Id" />

Thanks,
Shinu.
0
Uttam Dhakal
Top achievements
Rank 1
answered on 29 Oct 2012, 11:44 AM
main problem is my navigate url is not that simple.it is calculated based upon the values of columns which is provided as a stringbuilder collection and i have few server variables like current web.url and ID along with a URL that is hardcoded.
it is pretty complex to generate the URL i can't do it from client side.
Is there a way i can set the navigate URL property in Server Side Dynamically.
0
Accepted
Shinu
Top achievements
Rank 2
answered on 30 Oct 2012, 03:49 AM
Hi,

You can set the NavigateUrl property in Server Side as follows.

ASPX:
<telerik:GridHyperLinkColumn DataTextField="Id" UniqueName="Id" HeaderText="Id" SortExpression="Id" />

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem ditem = (GridDataItem)e.Item;
        HyperLink hyper = (HyperLink)ditem["Id"].Controls[0];
        hyper.NavigateUrl="Your url";
    }
}

Thanks,
Shinu.
Tags
Grid
Asked by
Uttam Dhakal
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Uttam Dhakal
Top achievements
Rank 1
Share this question
or