Hi,
I want to allow sorting in my grid when there is data and disallow sorting when there is no data.
But i find out that once i disallow sorting in NeedDatasource event , it will forever disallow sorting . And i find out that my code in allow/disallow sorting in ItemDataBound event do not work at all.
Below is my code !!
Does anyone has any idea?
HELP Please!!
I want to allow sorting in my grid when there is data and disallow sorting when there is no data.
But i find out that once i disallow sorting in NeedDatasource event , it will forever disallow sorting . And i find out that my code in allow/disallow sorting in ItemDataBound event do not work at all.
Below is my code !!
Protected Sub ajaxMsg_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles ajaxMsg.NeedDataSource Dim Msg As String Dim dsMsg As New DataSet() Dim strProjectId As String Try Msg = "" strProjectId = ddlProjectId.SelectedItem.Text dsMsg = getMessageByCompNoAndProjectId(strProjectId, "") ajaxMsg.DataSource = dsMsg If dsMsg.Tables(0).Rows.Count = 0 Then ajaxMsg.AllowSorting = False Else ajaxMsg.AllowSorting = True End If Catch ex As Exception Msg = ex.Message.ToString.Replace("'", "") RadAjaxManager1.ResponseScripts.Add("alert('" + Msg + "');") End Try End Sub Protected Sub ajaxMsg_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles ajaxMsg.ItemDataBound If TypeOf e.Item Is Telerik.Web.UI.GridFooterItem Then If ajaxMsg.MasterTableView.Items.Count > 0 Then If ajaxMsg.EditIndexes.Count > 0 OrElse ajaxMsg.MasterTableView.IsItemInserted Then ajaxMsg.MasterTableView.SortExpressions.Clear() ' ajaxMsg.MasterTableView.AllowSorting = False ajaxMsg.AllowSorting = False Else ' ajaxMsg.MasterTableView.AllowSorting = True ajaxMsg.AllowSorting = True End If Else ajaxMsg.MasterTableView.SortExpressions.Clear() ajaxMsg.MasterTableView.AllowSorting = False If ajaxMsg.MasterTableView.NoMasterRecordsText = "" AndAlso Not ajaxMsg.MasterTableView.IsItemInserted Then ajaxMsg.MasterTableView.NoMasterRecordsText = Resources.Resource.Search_Display End If End If ElseIf TypeOf e.Item Is GridPagerItem Then ajaxMsg.MasterTableView.PagerStyle.PagerTextFormat = "{2}{3}{4} " + Resources.Resource.Page + " {0} " + Resources.Resource.Pageof + " {1}" Dim PageSizeCombo As RadComboBox PageSizeCombo = CType(e.Item.FindControl("PageSizeComboBox"), RadComboBox) PageSizeCombo.Visible = False ElseIf TypeOf e.Item Is Telerik.Web.UI.GridDataItem AndAlso Not (ajaxMsg.EditIndexes.Count > 0 OrElse ajaxMsg.MasterTableView.IsItemInserted) Then ajaxMsg.MasterTableView.NoMasterRecordsText = Resources.Resource.Search_Display ajaxMsg.MasterTableView.AllowSorting = True Dim commandItem As GridCommandItem commandItem = CType(ajaxMsg.MasterTableView.GetItems(Telerik.Web.UI.GridItemType.CommandItem)(0), GridCommandItem) commandItem.FindControl("ExportToCsvButton").Visible = True End If End SubDoes anyone has any idea?
HELP Please!!