Pat Lindley
Top achievements
Rank 1
Pat Lindley
asked on 21 Oct 2011, 04:29 PM
I'm having an issue where my sorting appears to be working properly on the client, but when i select a row from the sorted records, i get the data for that row from the previous, un-sorted record.
So if my original data set looked like:
12345
After the sort it looked like:
54321
And i select "4", programmatically it returns "2".
Any ideas?
Thanks in advanced for your help.
So if my original data set looked like:
12345
After the sort it looked like:
54321
And i select "4", programmatically it returns "2".
Any ideas?
Thanks in advanced for your help.
4 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 24 Oct 2011, 06:56 AM
Hello Pat Lindley,
How do you populating RadGrid? If you are using any advanced features in RadGrid like sorting,paging,filtering etc, please make sure that you have used Advanced DataBinding technique with Need DataSource event like below.
Grid / Advanced Data Binding
Please paste your complete code if this doesn't help.
Thanks,
Princy.
How do you populating RadGrid? If you are using any advanced features in RadGrid like sorting,paging,filtering etc, please make sure that you have used Advanced DataBinding technique with Need DataSource event like below.
Grid / Advanced Data Binding
Please paste your complete code if this doesn't help.
Thanks,
Princy.
0
Joe
Top achievements
Rank 1
answered on 08 Jul 2013, 04:42 PM
I have a similar problem with my selectedItem being out of sync after sorting occurs.
when the page first loads, the selected item shows correctly with what i see highlighted in the grid (top item). However after sorting, if I click the same index (top item), the DataItem still matches what it did before even though I'm expecting the new sorted item.
I have a static list that is my RadGrid.DataSource. I tried binding it in the NeedDataSource like you mentioned. I am originally setting the list and binding in the Page_Init (!IsPostBack) function of my C#.
here is the aspx with my RadGrid:
Any Help is much Appreciated! My goal is to get my list (which never changes) to be sortable and filterable, and the user selects a record and is able to run a report based on the record. I am close, but the selected Items are "Out of sync" after sorting.
Thank you so much!!
when the page first loads, the selected item shows correctly with what i see highlighted in the grid (top item). However after sorting, if I click the same index (top item), the DataItem still matches what it did before even though I'm expecting the new sorted item.
I have a static list that is my RadGrid.DataSource. I tried binding it in the NeedDataSource like you mentioned. I am originally setting the list and binding in the Page_Init (!IsPostBack) function of my C#.
here is the aspx with my RadGrid:
<telerik:RadGrid runat="server" AutoGenerateColumns="true" EnableViewState="true" OnNeedDataSource="Grid_NeedDataSource" AllowFilteringByColumn="true" EnableLinqExpressions="false" AllowPaging="False" AllowSorting="True" OnColumnCreated="Grid_ColumnCreated" CellSpacing="0" OnSelectedIndexChanged="Selection_Changed" > <GroupingSettings CaseSensitive="false" /> <ClientSettings EnableRowHoverStyle="True" EnablePostBackOnRowClick="True"> <Selecting AllowRowSelect="True"></Selecting> <Scrolling UseStaticHeaders="True" AllowScroll="True" SaveScrollPosition="True" ScrollHeight="400px"></Scrolling> </ClientSettings> </telerik:RadGrid>Any Help is much Appreciated! My goal is to get my list (which never changes) to be sortable and filterable, and the user selects a record and is able to run a report based on the record. I am close, but the selected Items are "Out of sync" after sorting.
Thank you so much!!
0
Joe
Top achievements
Rank 1
answered on 08 Jul 2013, 05:11 PM
Update: i rearranged where my binding happens, but the wrong selection issue is still occurring. Before the NeedsDataSource function was not firing during debugging, but now after my updates it is firing.
C#:
C#:
protected void Page_Init(object sender, EventArgs e) { if (IsPostBack) { pogrid.DataSource = null; // filteredPOList; pogrid.Rebind(); } else { .... pogrid.DataSource = null; // filteredPOList; pogrid.Rebind();}}protected void Grid_NeedDataSource(object source, GridNeedDataSourceEventArgs e) { pogrid.DataSource = filteredPOList; //pogrid.Rebind(); }0
Princy
Top achievements
Rank 2
answered on 12 Jul 2013, 07:07 AM
Hi Joe,
I was not able to replicate the issue that you mentioned. Below is the code I tried. Please note that data is sorted internally in the grid only for presentation purposes, but that sorting cannot apply to your data source as well. That means it will not sore the "list" that you are using to populate the RadGrid.Please have a look at the code snippet.If this doesn't help,please elaborate on your requirements and give your full code.
ASPX:
C#:
Thanks,
Princy
I was not able to replicate the issue that you mentioned. Below is the code I tried. Please note that data is sorted internally in the grid only for presentation purposes, but that sorting cannot apply to your data source as well. That means it will not sore the "list" that you are using to populate the RadGrid.Please have a look at the code snippet.If this doesn't help,please elaborate on your requirements and give your full code.
ASPX:
<telerik:RadGrid ID="pogrid" runat="server" AutoGenerateColumns="true" EnableViewState="true" OnNeedDataSource="Grid_NeedDataSource" AllowFilteringByColumn="true" EnableLinqExpressions="false" AllowPaging="False" AllowSorting="True" CellSpacing="0" OnSelectedIndexChanged="Selection_Changed"> <MasterTableView DataKeyNames="EmployeeID"> </MasterTableView> <GroupingSettings CaseSensitive="false" /> <ClientSettings EnableRowHoverStyle="True" EnablePostBackOnRowClick="True"> <Selecting AllowRowSelect="True"></Selecting> <Scrolling UseStaticHeaders="True" AllowScroll="True" SaveScrollPosition="True" ScrollHeight="400px"> </Scrolling> </ClientSettings></telerik:RadGrid>C#:
protected void Grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { pogrid.DataSource = GetData(); } public DataSet GetData() { //Your ConnectionString code to get Data } protected void Selection_Changed(object sender, EventArgs e) { GridDataItem selectedItem = (GridDataItem)pogrid.SelectedItems[0]; int itemindex = selectedItem.ItemIndex; string key = selectedItem.GetDataKeyValue("EmployeeID").ToString(); // Getting selected rows dataKeyvalue }Thanks,
Princy