Hi,
I have a grid with sorting enabled.
I build the columns in the code-behind.
The grid also have static headers enabled.
When I click a header for sorting, the column is being sorted.
But when I click the arrow to change to the other sorting state, the arrow jumps to the next column.
Every extra click jumps the arrow a column to the right, instead of flipping the arrow in the same column.
I use version 2013.2.717.40.
Please advise.
Thanks,
Guy.
I have a grid with sorting enabled.
I build the columns in the code-behind.
The grid also have static headers enabled.
When I click a header for sorting, the column is being sorted.
But when I click the arrow to change to the other sorting state, the arrow jumps to the next column.
Every extra click jumps the arrow a column to the right, instead of flipping the arrow in the same column.
I use version 2013.2.717.40.
Please advise.
Thanks,
Guy.
7 Answers, 1 is accepted
0
Segev
Top achievements
Rank 1
answered on 25 Nov 2013, 07:55 AM
Hi,
Do you have any update?
I tried with custom sorting, but the problem is the same.
I tried this:
I'm debugging it.
When clicking on the first column for the first time, it works, and it goes to the correct case in the switch.
In the second click on the first column, e.CommandArgument now contains the DataField of the second column.
Of course the expected behavior is that e.CommandArgument will be the same, and only e.OldSortOrder will be changed.
Please advise.
Thanks,
Guy.
Do you have any update?
I tried with custom sorting, but the problem is the same.
I tried this:
protected
void
RadGrid1_SortCommand(
object
source, GridSortCommandEventArgs e)
{
if
(Presenter.COLUMN_DOMAIN_PROJECT.Equals(e.CommandArgument))
{
switch
(e.OldSortOrder)
{
case
GridSortOrder.None:
break
;
case
GridSortOrder.Ascending:
break
;
case
GridSortOrder.Descending:
break
;
}
}
}
I'm debugging it.
When clicking on the first column for the first time, it works, and it goes to the correct case in the switch.
In the second click on the first column, e.CommandArgument now contains the DataField of the second column.
Of course the expected behavior is that e.CommandArgument will be the same, and only e.OldSortOrder will be changed.
Please advise.
Thanks,
Guy.
0
Princy
Top achievements
Rank 2
answered on 25 Nov 2013, 08:17 AM
Hi Segev,
I couldn't replicate the issue you are facing. Below is a sample code that i tried with the same version, please try it and see if the issue exists. Please provide your full code snippet if this doesn't help.
ASPX:
C#:
Thanks,
Princy
I couldn't replicate the issue you are facing. Below is a sample code that i tried with the same version, please try it and see if the issue exists. Please provide your full code snippet if this doesn't help.
ASPX:
<
asp:PlaceHolder
ID
=
"PlaceHolder1"
runat
=
"server"
></
asp:PlaceHolder
>
C#:
RadGrid RadGrid1;
protected
void
Page_Init(
object
source, System.EventArgs e)
{
RadGrid1 =
new
RadGrid();
RadGrid1.MasterTableView.DataKeyNames =
new
string
[] {
"OrderID"
};
RadGrid1.Skin =
"Default"
;
RadGrid1.Width = Unit.Percentage(100);
RadGrid1.PageSize = 15;
RadGrid1.AllowPaging =
true
;
RadGrid1.AutoGenerateColumns =
false
;
RadGrid1.AllowSorting =
true
;
RadGrid1.ClientSettings.Scrolling.UseStaticHeaders =
true
;
RadGrid1.NeedDataSource +=
new
GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
//Add columns
GridBoundColumn boundColumn;
boundColumn =
new
GridBoundColumn();
RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField =
"OrderID"
;
boundColumn.HeaderText =
"OrderID"
;
boundColumn.SortExpression =
"OrderID"
;
boundColumn =
new
GridBoundColumn();
RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField =
"ShipCountry"
;
boundColumn.HeaderText =
"ShipCountry"
;
boundColumn.SortExpression =
"ShipCountry"
;
boundColumn =
new
GridBoundColumn();
RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField =
"CustomerID"
;
boundColumn.HeaderText =
"CustomerID"
;
boundColumn.SortExpression =
"CustomerID"
;
this
.PlaceHolder1.Controls.Add(RadGrid1);
}
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = GetDataTable(
"SELECT * FROM Orders"
);
}
Thanks,
Princy
0
Segev
Top achievements
Rank 1
answered on 12 Dec 2013, 07:29 AM
Hi Princy,
I've tried exactly what you've suggested.
In the markup - only a PlaceHolder.
In the code-behind - all the grid's definition, the columns, and the data binding.
I have the same problem.
When sorting the first column by clicking the header, everything is OK.
But when clicking the small sorting arrow, in order to change the sorting state, the sorting "jumps" to the second column.
When clicking the arrow of the second column, it "jumps" to the third column.
See the attached image.
Thanks,
Guy.
I've tried exactly what you've suggested.
In the markup - only a PlaceHolder.
In the code-behind - all the grid's definition, the columns, and the data binding.
I have the same problem.
When sorting the first column by clicking the header, everything is OK.
But when clicking the small sorting arrow, in order to change the sorting state, the sorting "jumps" to the second column.
When clicking the arrow of the second column, it "jumps" to the third column.
See the attached image.
Thanks,
Guy.
0
Hi Guy,
Please note that when generating a grid in the Page_Init event handler, grid columns should be added to the Columns collection of the MasterTableView after their attributes are set:
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html#Section22
Please make the suggested modification and let me know about the result.
Regards,
Eyup
Telerik
Please note that when generating a grid in the Page_Init event handler, grid columns should be added to the Columns collection of the MasterTableView after their attributes are set:
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html#Section22
Please make the suggested modification and let me know about the result.
Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Mansi
Top achievements
Rank 1
answered on 08 Jul 2014, 07:23 PM
I'm facing the same problem.
I have a grid with sorting enabled.
I build the columns in the code-behind.
When I click a header for sorting, the column is being sorted.
But when I click the arrow to change to the other sorting state, the arrow jumps to the next column.
Every extra click jumps the arrow a column to the right, instead of flipping the arrow in the same column.
Really Appreciate reply.
I have a grid with sorting enabled.
I build the columns in the code-behind.
When I click a header for sorting, the column is being sorted.
But when I click the arrow to change to the other sorting state, the arrow jumps to the next column.
Every extra click jumps the arrow a column to the right, instead of flipping the arrow in the same column.
Really Appreciate reply.
0
Princy
Top achievements
Rank 2
answered on 09 Jul 2014, 06:45 AM
Hi Mansi,
This is not an expected behavior. Can you please try the below sample code snippet and check if the issue exist. Provide your full code and version details if you are not able to replicate the issue.
ASPX:
C#:
Thanks,
Princy
This is not an expected behavior. Can you please try the below sample code snippet and check if the issue exist. Provide your full code and version details if you are not able to replicate the issue.
ASPX:
<
asp:PlaceHolder
ID
=
"phGrid"
runat
=
"server"
></
asp:PlaceHolder
>
C#:
RadGrid RadGrid;
protected
void
Page_Init(
object
source, System.EventArgs e)
{
RadGrid =
new
RadGrid();
RadGrid.ID =
"RadGridSample"
;
RadGrid.MasterTableView.DataKeyNames =
new
string
[] {
"ID"
};
RadGrid.AutoGenerateColumns =
false
;
RadGrid.AllowSorting =
true
;
RadGrid.NeedDataSource +=
new
GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
GridBoundColumn boundColumn;
boundColumn =
new
GridBoundColumn();
boundColumn.DataField =
"ID"
;
boundColumn.HeaderText =
"ID"
;
boundColumn.SortExpression =
"ID"
;
RadGrid.MasterTableView.Columns.Add(boundColumn);
boundColumn =
new
GridBoundColumn();
boundColumn.DataField =
"Name"
;
boundColumn.HeaderText =
"Name"
;
boundColumn.SortExpression =
"Name"
;
RadGrid.MasterTableView.Columns.Add(boundColumn);
boundColumn =
new
GridBoundColumn();
boundColumn.DataField =
"Number"
;
boundColumn.HeaderText =
"Number"
;
boundColumn.SortExpression =
"Number"
;
RadGrid.MasterTableView.Columns.Add(boundColumn);
this
.phGrid.Controls.Add(RadGrid);
}
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
dynamic data =
new
[] {
new
{ ID = 1, Name =
"Name1"
, Number=44},
new
{ ID = 2, Name =
"Name2"
, Number=0},
new
{ ID = 3, Name =
"Name3"
, Number=44},
new
{ ID = 4, Name =
"Name9"
, Number=0},
new
{ ID = 5, Name =
"Name5"
, Number=0},
new
{ ID = 6, Name =
"Name6"
, Number=44},
new
{ ID = 7, Name =
"Name9"
, Number=10},
new
{ ID = 8, Name =
"Name3"
, Number=10},
new
{ ID = 9, Name =
"Name9"
, Number=0}
};
RadGrid.DataSource = data;
}
Thanks,
Princy
0
Mansi
Top achievements
Rank 1
answered on 30 Jul 2014, 04:03 PM
Hi Princy,,
I solved the problem by advanced data binding.. http://www.telerik.com/help/aspnet-ajax/grid-advanced-data-binding.html
I was explicitly binding the grid. but Using NeedSource event.. its all solved..
Thanks,
Mansi
I solved the problem by advanced data binding.. http://www.telerik.com/help/aspnet-ajax/grid-advanced-data-binding.html
I was explicitly binding the grid. but Using NeedSource event.. its all solved..
Thanks,
Mansi