Hi,
I'm using RadGrid. I implement paging and sorting on the grid but the header text is missing after i click the header text for the sorting.
Paging is working fine.
Is there something i missing here?
I'm using RadGrid. I implement paging and sorting on the grid but the header text is missing after i click the header text for the sorting.
Paging is working fine.
<telerik:RadGrid ID="RadGrid" runat="server" AllowPaging="True" AllowSorting = "True" PageSize="10" AutoGenerateColumns="false" GridLines="None" OnNeedDataSource="RadGrid_NeedDataSource"> |
<PagerStyle Visible="True" /> |
<MasterTableView TableLayout="Fixed" AllowMultiColumnSorting="true" > |
</MasterTableView> |
<SortingSettings SortedBackColor="Azure" EnableSkinSortStyles="false" /> |
<ClientSettings> |
<Selecting AllowRowSelect="true" /> |
</ClientSettings> |
</telerik:RadGrid> |
Is there something i missing here?
7 Answers, 1 is accepted
0
Hello Sholehuddin,
The online example below represents the desired functionality. Please, examine it and see what is the difference in your scenario:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/sorting/defaultcs.aspx
I hope this helps.
Best wishes,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
The online example below represents the desired functionality. Please, examine it and see what is the difference in your scenario:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/sorting/defaultcs.aspx
I hope this helps.
Best wishes,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

shoden
Top achievements
Rank 1
answered on 02 Apr 2010, 02:51 AM
Yesterday, I try and error. i just init the grid column and bind the grid again on page load each time the grid sorting;now its working. Previously i try to bind in needdatasource but not working. If not mistaken, caling .Rebind() also not working
Since my grid is dynamically load and bind(init column and binding is during runtime). Do i need to keep calling
Since my grid is dynamically load and bind(init column and binding is during runtime). Do i need to keep calling
"RadGrid1.DataSource = DataView1" each time i perform sorting or filtering?
0
Hello Shoden,
Attached to this message is a simple working application which handle the desired functionality. PLease examine it and let me know if it works as expected.
I hope this helps.
Kind regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Attached to this message is a simple working application which handle the desired functionality. PLease examine it and let me know if it works as expected.
I hope this helps.
Kind regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

shoden
Top achievements
Rank 1
answered on 02 Apr 2010, 12:06 PM
This is the sample code. I just want to know how to implement sort and grouping base on this source code. Thanks
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="RadGrid._Default" %> |
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml" > |
<head runat="server"> |
<title></title> |
</head> |
<body> |
<form id="form1" runat="server"> |
<div> |
<asp:ScriptManager ID="ScriptManager1" runat="server"> |
</asp:ScriptManager> |
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" |
DefaultLoadingPanelID="RadAjaxLoadingPanel1"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="RadGrid1"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="RadGrid1" |
LoadingPanelID="RadAjaxLoadingPanel1" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManager> |
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default"> |
</telerik:RadAjaxLoadingPanel> |
<telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True"> |
<HeaderContextMenu EnableAutoScroll="True"></HeaderContextMenu> |
<MasterTableView> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
</MasterTableView> |
</telerik:RadGrid> |
</div> |
</form> |
</body> |
</html> |
Imports System.Data.OleDb |
Imports Telerik.Web.UI |
Partial Public Class _Default |
Inherits System.Web.UI.Page |
Private conn As OleDbConnection |
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
If Not Page.IsPostBack Then |
InitGrid() |
BindGrid() |
End If |
End Sub |
Private Sub InitGrid() |
Dim adapter As OleDbDataAdapter = New OleDbDataAdapter() |
adapter.SelectCommand = New OleDbCommand("SELECT * FROM Customers", conn) |
Dim myDataTable As DataTable = New DataTable("Customers") |
Dim column As GridColumn |
conn.Open() |
adapter.Fill(myDataTable) |
Dim dc As DataColumn |
For Each dc In myDataTable.Columns |
column = New GridBoundColumn |
With CType(column, GridBoundColumn) |
.DataField = dc.ColumnName |
.HeaderText = dc.Caption |
End With |
If dc.ColumnName = "ContactTitle" Then |
Dim grp As New GridGroupByExpression |
Dim ggbf As New GridGroupByField |
ggbf.FieldAlias = "Group" |
ggbf.FieldName = dc.ColumnName |
ggbf.SortOrder = GridSortOrder.Ascending |
ggbf.HeaderValueSeparator = " by " & dc.ColumnName & ": " |
grp.GroupByFields.Add(ggbf) |
grp.SelectFields.Add(ggbf) |
RadGrid1.MasterTableView.GroupByExpressions.Add(grp) |
End If |
RadGrid1.Columns.Add(column) |
Next |
conn.Close() |
End Sub |
Private Sub BindGrid() |
Dim adapter As OleDbDataAdapter = New OleDbDataAdapter() |
adapter.SelectCommand = New OleDbCommand("SELECT * FROM Customers", conn) |
Dim myDataTable As DataTable = New DataTable("Customers") |
conn.Open() |
adapter.Fill(myDataTable) |
RadGrid1.DataSource = myDataTable |
conn.Close() |
End Sub |
Public Sub New() |
If conn Is Nothing Then |
conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("~/App_Data/Nwind.mdb")) |
End If |
End Sub |
Private Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource |
InitGrid() |
BindGrid() |
End Sub |
End Class |
0
Hi Shoden,
In case you need to create the structure of your grid programmatically, please have in mind that the columns should be added to the corresponding collection first, before the values for their properties are set. This is important because no ViewState is managed for the object before it has been added to the corresponding collection.
For more information about how to create the structure of a grid in the Page_Load event handler, go through the following links:
On PageLoad
Programmatic creation
Regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
In case you need to create the structure of your grid programmatically, please have in mind that the columns should be added to the corresponding collection first, before the values for their properties are set. This is important because no ViewState is managed for the object before it has been added to the corresponding collection.
For more information about how to create the structure of a grid in the Page_Load event handler, go through the following links:
On PageLoad
Programmatic creation
Regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

shoden
Top achievements
Rank 1
answered on 06 Apr 2010, 05:32 AM
thank that works out but just curious...
how come this code works
but this code is not working
how come this code works
Dim dc As DataColumn |
For Each dc In myDataTable.Columns |
column = New GridBoundColumn |
RadGrid1.MasterTableView.Columns.Add(column) |
With CType(column, GridBoundColumn) |
.DataField = dc.ColumnName |
.HeaderText = dc.Caption |
End With |
Next |
but this code is not working
Dim dc As DataColumn |
For Each dc In myDataTable.Columns |
column = New GridBoundColumn |
With CType(column, GridBoundColumn) |
.DataField = dc.ColumnName |
.HeaderText = dc.Caption |
End With |
RadGrid1.MasterTableView.Columns.Add(column) |
Next |
0
Accepted
Hi,
As I said in the previous post in order to define the structure of a RadGrid control that is declared in the ASPX page, use the Page_Load event handler. Columns and detail table should be added to the corresponding collection first, before the values for their properties are set.
When generating RadGrid instance entirely in code, you should use the Page_Init event handler. When generating a grid in the Page_Init event handler, grid columns should be added to the Controls collection of the MasterTableView after their attributes are set. No ViewState is required for grid structure to be persisted as it is recreated on each page initialization.
Best wishes,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
As I said in the previous post in order to define the structure of a RadGrid control that is declared in the ASPX page, use the Page_Load event handler. Columns and detail table should be added to the corresponding collection first, before the values for their properties are set.
When generating RadGrid instance entirely in code, you should use the Page_Init event handler. When generating a grid in the Page_Init event handler, grid columns should be added to the Controls collection of the MasterTableView after their attributes are set. No ViewState is required for grid structure to be persisted as it is recreated on each page initialization.
Best wishes,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.