Good morning,
This is not an issue but more asking for advice . . .
I have a RadGrid with several GridTemplateColumns that contain a label. In the code-behind page's RadGrid_ItemDataBound event, I have some logic that will set the text of this label based on several conditions, such as this:
I would like for my users to be able to sort on these GridTemplateColumns but not sure how to do this. There is no single field in the datasource I can use for the sort, as you can see above, the values shown in the columns are dependent on several columns.
How can I get the RadGrid to sort on the actual value shown in the column?
This is not an issue but more asking for advice . . .
I have a RadGrid with several GridTemplateColumns that contain a label. In the code-behind page's RadGrid_ItemDataBound event, I have some logic that will set the text of this label based on several conditions, such as this:
Protected Sub rgStoresMissingFiles_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles rgStoresMissingFiles.ItemDataBound
If e.Item.ItemType = Telerik.Web.UI.GridItemType.Item Or e.Item.ItemType = Telerik.Web.UI.GridItemType.AlternatingItem Then
Dim lblConnectionStatus As Label = e.Item.FindControl("lblConnectionStatus")
Dim lblNextPollTime As Label = e.Item.FindControl("lblNextPollTime")
Dim lblLastConnectTime As Label = e.Item.FindControl("lblLastConnectTime")
Dim warningcolor As Drawing.Color = Drawing.Color.FromArgb(244, 244, 185)
Dim errorcolor As Drawing.Color = Drawing.Color.FromArgb(253, 125, 249)
With e.Item.DataItem
Dim strLastConnectTime As String = CType(e.Item.DataItem("last_connect_time"), DateTime).ToString("hh:mm tt")
Dim strNextConnectTime As String = CType(e.Item.DataItem("poll_now_time"), DateTime).ToString("hh:mm tt")
If e.Item.DataItem("currently_polling") Then
lblConnectionStatus.Text = "Currently polling"
ElseIf e.Item.DataItem("last_connect_time") > Now().ToShortDateString Then
lblLastConnectTime.Text = strLastConnectTime
Select Case e.Item.DataItem("last_connect_status_id")
Case 3 ' NoConnect
lblConnectionStatus.Text = "Unable to connect to store"
lblNextPollTime.Text = "Queued"
e.Item.BackColor = errorcolor
Case 2 ' ConnectNoData
lblConnectionStatus.Text = "Potential line problem"
lblNextPollTime.Text = strNextConnectTime
e.Item.BackColor = errorcolor
Case 1 ' ConnectWithData
If e.Item.DataItem("count_staged_archives") > 0 Then
lblConnectionStatus.Text = "Data polled"
lblNextPollTime.Text = "Data staged"
ElseIf e.Item.DataItem("count_staged_archives") = 0 And e.Item.DataItem("count_loaded_archives") > 0 Then
lblConnectionStatus.Text = "Connected, missing data"
lblNextPollTime.Text = strNextConnectTime
e.Item.BackColor = warningcolor
End If
End Select
ElseIf e.Item.DataItem("poll_now") Then
lblConnectionStatus.Text = "Staged for first poll"
lblNextPollTime.Text = strNextConnectTime
lblLastConnectTime.Text = "N/A"
Else
lblConnectionStatus.Text = "Staged for first poll"
lblNextPollTime.Text = "Queued"
lblLastConnectTime.Text = "N/A"
End If
End With
End If
End Sub
I would like for my users to be able to sort on these GridTemplateColumns but not sure how to do this. There is no single field in the datasource I can use for the sort, as you can see above, the values shown in the columns are dependent on several columns.
How can I get the RadGrid to sort on the actual value shown in the column?