Hello, I have an issue with the sort expression feature in the RadGrid.
As said in several post, i'm using the advanced databinding with NeedDataSource to make the sorting works correctly.
This is my grid definitions:
Pretty simple grid with simple data i load from a list for this test purpose.
On load, i check if the dataSource is nothing, then call Rebind() to call NeedDataSource()
Once its called, i bind my grid with data.
I got this on load....
The sorting doesnt work well, so i use the HeaderContextMenuClick event to output what's going on...
So my grid has the expression it needs, but the sorting doesnt occur.
So i placed a couple of debug.print... Here what i get after click on "sort asc" on "Unit price" column:
Rebind is supposed to call NeedDataSource right? I tried to call MyRadGrid.datasource manualy... but still no result, the grid wont sort.
Plus, i get a empty button (5-8pixel width, 2-3 pixels height) beside the header text after i call Clear sorting.. this happens only in my test, not my project.
I have no idea why this isnt working. Can anyone help me?
Thanks!
As said in several post, i'm using the advanced databinding with NeedDataSource to make the sorting works correctly.
This is my grid definitions:
<telerik:RadGrid ID="MyRadGrid" runat="server" AllowSorting="true" EnableHeaderContextMenu="true" Width="900px" CssClass="RadGridCustomClass"> <ClientSettings AllowColumnsReorder="true" ReorderColumnsOnClient="true" ColumnsReorderMethod="Reorder" AllowColumnHide="true" > <Resizing AllowColumnResize="true" EnableRealTimeResize="true" ResizeGridOnColumnResize="true" ClipCellContentOnResize="true" AllowRowResize="false" /> </ClientSettings> <HeaderContextMenu EnableRoundedCorners="true" EnableShadows="true" OnItemClick="MyRadGrid_HeaderContextMenuClick" /> <MasterTableView AllowMultiColumnSorting="false" AllowCustomSorting="true" AllowCustomPaging="true" TableLayout="Fixed" AutoGenerateColumns="false" EnableHeaderContextMenu="true" EnableViewState="false" > <Columns> <telerik:GridBoundColumn DataField="ID" SortExpression="ID" HeaderText="ID" DataType="System.Int32" /> <telerik:GridBoundColumn DataField="Name" SortExpression="Name" HeaderText="Name" DataType="System.String" /> <telerik:GridNumericColumn DataField="UnitPrice" SortExpression="UnitPrice" HeaderText="Unit price" DataType="System.Decimal" /> <telerik:GridBoundColumn DataField="Date" SortExpression="Date" DataFormatString="{0:d}" HeaderText="Date" DataType="System.DateTime" /> <telerik:GridCheckBoxColumn DataField="Discontinued" SortExpression="Discontinued" HeaderText="Discontinued" DataType="System.Boolean" /> </Columns></MasterTableView></telerik:RadGrid>Pretty simple grid with simple data i load from a list for this test purpose.
On load, i check if the dataSource is nothing, then call Rebind() to call NeedDataSource()
Once its called, i bind my grid with data.
I got this on load....
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If MyRadGrid.DataSource Is Nothing Then MyRadGrid.Rebind() End IfEnd SubPrivate Sub MyRadGrid_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles MyRadGrid.NeedDataSource Dim list2 As New List(Of MyBusinessObject)() For j As Integer = 0 To 5 Dim Product1 As New MyBusinessObject()'Some local data Product1.ID = j Product1.Name = names(j) Product1.UnitPrice = prizes(j) Product1.[Date] = dates(j) Product1.Discontinued = bools(j) list2.Add(Product1) Next MyRadGrid.DataSource = list2End SubPublic Sub MyRadGrid_HeaderContextMenuClick(ByVal sender As Object, ByVal e As RadMenuEventArgs) If e.Item.Value <> "SortAsc" And e.Item.Value <> "SortDesc" Then MyRadGrid.MasterTableView.SortExpressions.Clear() End If MyRadGrid.Rebind() 'i tried MyRadGrid.MasterTableView.Rebind()End SubThe sorting doesnt work well, so i use the HeaderContextMenuClick event to output what's going on...
So my grid has the expression it needs, but the sorting doesnt occur.
So i placed a couple of debug.print... Here what i get after click on "sort asc" on "Unit price" column:
******************************Page loadPage load() data source is nothing... Calling MyRadGrid.Rebind()MyRadGrid_NeedDataSource()******************************Page loadPage load() data source is nothing... Calling MyRadGrid.Rebind()MyRadGrid_NeedDataSource()'WebDev.WebServer.EXE' (Managed): Loaded 'D:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualBasic\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualBasic.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.MyRadGrid_HeaderContextMenuClick() SORT EXPRESSION: Name:UnitPrice Order:Ascending
MyRadGrid_HeaderContextMenuClick() Calling MyRadGrid.Rebind()
Rebind is supposed to call NeedDataSource right? I tried to call MyRadGrid.datasource manualy... but still no result, the grid wont sort.
Plus, i get a empty button (5-8pixel width, 2-3 pixels height) beside the header text after i call Clear sorting.. this happens only in my test, not my project.
I have no idea why this isnt working. Can anyone help me?
Thanks!