I am testing the Radgrid, and i am facing a problem with the sort. I am manually binding the data source.
My data source is a Enumerable type that is returned from a linq query. The grid show the values correctly, but when i try to sort any column the column header disappear and the content of the table stay inalterable.
Regards
3 Answers, 1 is accepted
Generally automatic grid sorting is supported only with advanced data-binding using NeedDataSource or DataSourceID. Can you post a bit mo info about how the grid is bound in your case?
Best wishes,
Vlad
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Because my application requires many grids, I am testing it by having the grid created in markup and then defining the column structure programmatically.
Using the code below, everything loads correctly (both grid structure, appearance and data). However, when I start to use the grid interactively, I am having two problems.
First, like Rui, when I click on a column heading to sort, the sort works, but the text in the column heading disappears.
Second, when I enter a filter value on a column, the values in the cells of all columns come back as "System.Data.DataRowView".
I was thinking of trying to create the grid 100% programatically - is that an issue, or is there something else I'm missing? By the way, I have created this same grid all declaratively in another test page and it all works there. This programmatic creation is using all the same data, column structure and properties as the other test one.
<
telerik:RadGrid
ID="RadGrid1"
runat="server"
Height="450px"
Width="900px"
AllowSorting="True"
AllowMultiRowSelection="True"
AllowPaging="True"
AllowFilteringByColumn="True"
ShowGroupPanel="True"
ShowStatusBar="True"
StatusBarSettings-LoadingText="Loading..."
StatusBarSettings-ReadyText="Done"
GridLines="None"
AutoGenerateColumns="False"
PageSize="100">
<PagerStyle Mode="NextPrevAndNumeric" />
<%
--***** Master Table View Created Here Dynamically *****--%>
<ClientSettings AllowDragToGroup="True" AllowColumnsReorder="True">
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
<Resizing AllowColumnResize="True" ClipCellContentOnResize = "False" />
</ClientSettings>
<StatusBarSettings ReadyText="Done" />
</telerik:RadGrid>
Private
Sub BuildInboxGrid()
RadGrid1.Skin =
"Office2007"
With RadGrid1.MasterTableView
.AllowNaturalSort =
False
.GroupsDefaultExpanded =
False
.Width = 900
.TableLayout = GridTableLayout.Auto
.CommandItemDisplay = GridCommandItemDisplay.None
.CurrentResetPageIndexAction = GridResetPageIndexAction.SetPageIndexToFirst
.Frame = GridTableFrame.Border
End With
Dim boundColumn As GridBoundColumn
boundColumn =
New GridBoundColumn
boundColumn.DataField =
"Target__ObjectTypeName"
boundColumn.UniqueName =
"Target__ObjectTypeName"
boundColumn.SortExpression =
"Target__ObjectTypeName"
boundColumn.HeaderText =
"Type"
boundColumn.FilterListOptions = GridFilterListOptions.VaryByDataType
boundColumn.GroupByExpression =
"Target__ObjectTypeName, count(ObjectID) DocCount, sum(isRead) ReadCount Group By Target__ObjectTypeName"
boundColumn.HeaderStyle.Width = 120
RadGrid1.MasterTableView.Columns.Add(boundColumn)
boundColumn =
New GridBoundColumn
With boundColumn
.DataField =
"ProjectShortName"
.Display =
"true"
.UniqueName =
"ProjectShortName"
.SortExpression =
"ProjectShortName"
.HeaderText =
"Project"
.FilterListOptions = GridFilterListOptions.VaryByDataType
.GroupByExpression =
"ProjectNumber, ProjectShortName, count(ObjectID) DocCount Group By ProjectNumber"
.HeaderStyle.Width = 120
End With
RadGrid1.MasterTableView.Columns.Add(boundColumn)
End Sub
Private
Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
RadGrid1.DataSource =
Me.GridData
End Sub
Private
ReadOnly Property GridData() As DataSet
Get
Dim res As Object = Me.ViewState("GridData")
If Not (res Is Nothing) Then
Return CType(res, DataSet)
End If
Dim ds As DataSet
'Eventually will need to do a select case here to determine exactly
'which(Grid) 's data to retrieve. For now, all we have is the inbox.
ds = GetInboxData()
Me.ViewState("GridData") = ds
Return ds
End Get
End Property
In the codebehind, after creating the column instance, I needed to add it to the collection before setting all of its properties. This is clear in the docs - all I had to do was read them :)
