This is a migrated thread and some comments may be shown as answers.

Sort only works on first and last page

5 Answers 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dean Killam
Top achievements
Rank 1
Dean Killam asked on 14 Aug 2008, 05:41 PM
hello,

 i am using the radgrid inside a multi page view with LINQ and the paging style set to slider. the sorting function for the grid only works on the first and last pages of the results. If i select any other grid page the grid displays no data


ASPX

<telerik:RadTabStrip Skin = "Sunset" MultiPageID="RadMultiPage1" ID="RadTabStrip1" runat="server">

<Tabs>

<telerik:RadTab Text="General">

</telerik:RadTab>

<telerik:RadTab Text="Tools">

</telerik:RadTab>

</Tabs>

</telerik:RadTabStrip>

<telerik:RadMultiPage ID="RadMultiPage1" runat="server">

<telerik:RadPageView ID = "RadPageView1" runat = "server" >

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>

<table style="width:100%;">

<tr><td>Test 1</td><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td colspan="3">

<telerik:RadGrid OnSortCommand="RadGrid1_SortCommand" AllowSorting="True"

AllowPaging = "true" PageSize = "5" AutoGenerateColumns = "False" ID="RadGrid1" runat="server"

Skin="Sunset" Width="275px" onneeddatasource="RadGrid1_NeedDataSource">

<MasterTableView DataKeyNames="customer_id" >

<Columns>

<telerik:GridBoundColumn DataField="customer_id" HeaderText="QA Number" >

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="customer_name" SortExpression = "customer_name" HeaderText="Can Reply" >

</telerik:GridBoundColumn>

</Columns>

</MasterTableView>

<PagerStyle Mode="Slider"></PagerStyle>

</telerik:RadGrid>

</td></tr>

<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

</table>

</ContentTemplate>

</asp:UpdatePanel>

</telerik:RadPageView>

<telerik:RadPageView ID="RadPageView2" runat="server">

<table style="width:100%;">

<tr><td>Test 2</td><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

</table>

</telerik:RadPageView>

</telerik:RadMultiPage>

ASPX.CS

protected void Page_Load(object sender, EventArgs e)

{

List<gen_customer> customers = (from c in db.gen_customers

where c.customer_id < 103

select c).ToList<gen_customer>();

RadGrid1.DataSource = customers;

RadGrid1.DataBind();

}

protected void RadGrid1_SortCommand(object source, Telerik.Web.UI.GridSortCommandEventArgs e)

{

if (!e.Item.OwnerTableView.SortExpressions.ContainsExpression(e.SortExpression))

{

GridSortExpression sortExpr = new GridSortExpression();

sortExpr.FieldName = e.SortExpression;

sortExpr.SortOrder =

GridSortOrder.Ascending;

e.Item.OwnerTableView.SortExpressions.AddSortExpression(sortExpr);

}

}

 

protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)

{

List<gen_customer> customers = (from c in db.gen_customers

where c.customer_id < 103

select c).ToList<gen_customer>();

RadGrid1.DataSource = customers;

}

 

5 Answers, 1 is accepted

Sort by
0
Dean Killam
Top achievements
Rank 1
answered on 14 Aug 2008, 06:04 PM
actually the sorting only works correctly on the first page of results. for example if the grid returns 20 pages of results sort will only work on the first page  of the 20
0
Vlad
Telerik team
answered on 15 Aug 2008, 06:02 AM
Hello Dean,

You do not need the Page_Load and SortCommand code - just pass your data source to the grid in NeedDataSource.

Best wishes,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Dean Killam
Top achievements
Rank 1
answered on 15 Aug 2008, 02:18 PM
removing the sort command did not fix the problem
0
Dean Killam
Top achievements
Rank 1
answered on 15 Aug 2008, 03:23 PM
If possible can you please send me a very basic example that uses the following criteria? i think that would be the best way to solve this issue!

1)RAD for asp.net ajax 2008 Q1
2)Either VS2005 or VS2008
2) LINQ data access (NOT an inline object data source thats declared in the markup)
3) Slider paging style top and bottom positioning
4) basic sorting asc/desc by clicking the grid columns


Thanks!
0
Konstantin Petkov
Telerik team
answered on 19 Aug 2008, 07:42 AM
Hi Dean,

You can review the forum thread here discussing the RadGrid with LinqDataSource. There is a demo referred in our first response. Since the paging is added as well you just need to switch to the slider pager mode. You can also find another demo in this thread.

Best wishes,
Konstantin Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Dean Killam
Top achievements
Rank 1
Answers by
Dean Killam
Top achievements
Rank 1
Vlad
Telerik team
Konstantin Petkov
Telerik team
Share this question
or