13 Answers, 1 is accepted
Thank you for contacting us. Well, the data is sorted internally in the grid only for presentation purposes, but that sorting cannot apply to your data source as well. Please extend on your scenario. Perhaps you can just access the data through the grid where it is sorted. You can find examples in our documentation.
Best wishes,
Nick
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.
I have a similar requirement. Here's the scenario.
1. User sorts by one or many columns on the grid.
2. The user requests to print to PDF.
3. The PDF prints while preserving the sort order specified by the user.
Previously, we used a standard GridView and simply sorted the DataSet before binding to the GridView. It was then easy to print according to the order of the DataSet displayed by the GridView. How can we accomplish this using RadGrid?
Thanks,
Jonah
Sadly i do not understand the problem here, once the user has sorted the grid in any way required, you can just export that grid as is, and the exported data will be sorted and display just the way it was in the grid.
Please take a look at this help article on exporting data using RadGridView
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
I am sorting the radgrid after sorting the data in dataset is not sorting,
I have a scenario for this iam adding new rows form grid,new rows are updating to dataset.(there is no Datakey for thease records)
after sorting,issue comes with deleting,i need to delete record for that iam using e.item.datasetindex which is pointing to diff record in dataset.
Please help me how to fix this issue.
Thanks,
Raj
Thank you for writing.
You can delete the record using the DataBoundItem property of GridViewRowInfo instance. The DataBoundItem can be cast to DataRowView and then you can get the reference to DataRow item. Here is a sample example using CurrentRow of RadGridView:
protected
override
void
OnButton1Click()
{
DataRowView rowView = gridView.CurrentRow.DataBoundItem
as
DataRowView;
rowView.DataView.Table.Rows.Remove(rowView.Row);
}
The proposed approach, makes this manipulation universal, so it will not matter if the grid is sorted or filtered.
I hope this helps.
All the best,
Julian Benkov
the Telerik team
Thanks for your reply.
The above is not working for me iam using Wed Radgrid.i didnt find any
DataRowView rowView = radgrid.DataBoundItem as DataRowView;
Below is my sample code.
protected void radgrid_DeleteCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
oCashDetailDS.Tables[
"table1"].Rows.RemoveAt(e.Item.DataSetIndex);
}
With out sorting its working fine but after sorting e.Item.DataSetIndex producing dataset index, but it is not equavalent main dataset datasetindex with this deleting diff record in Main Dataset.
Same e.item.datasetindex using for Updating the record also.
Please help me out with this issue.
Thanks,
raj
Please note that this forum concerns RadGridView for WinForms rather than RadGrid for ASP.NET AJAX. Please address your question in the appropriate forum (http://www.telerik.com/community/forums/aspnet-ajax/grid.aspx) so the corresponding team can handle it.
All the best,
Stefan
the Telerik team
Protected
Sub
RadGrid1_DeleteCommand(sender
As
Object
, e
As
GridCommandEventArgs)
Handles
RadGrid1.DeleteCommand
Dim
dtRecords
As
DataTable =
DirectCast
(ViewState(
"dtBooks"
), DataTable)
dtRecords.Rows.Clear()
For
Each
col
As
GridColumn
In
RadGrid1.Columns
Dim
colString
As
New
DataColumn(col.UniqueName)
dtRecords.Columns.Add(colString)
Next
For
Each
row
As
GridDataItem
In
RadGrid1.MasterTableView.Items
'loops through each rows in RadGrid
Dim
dr
As
DataRow = dtRecords.NewRow()
For
Each
col
As
GridColumn
In
RadGrid1.MasterTableView.AutoGeneratedColumns
'loops through each AutoGenerated column in RadGrid
dr(col.UniqueName) = row(col.UniqueName).Text
Next
dtRecords.Rows.Add(dr)
Next
RadGrid1.DataSource = dtRecords
RadGrid1.DataBind()
Dim
rowID
As
Integer
= e.Item.DataSetIndex
Dim
dt
As
DataTable =
DirectCast
(ViewState(
"dtBooks"
), DataTable)
dt.Rows.Remove(dt.Rows(rowID))
ViewState(
"dtBooks"
) = dt
RadGrid1.DataSource = dt
RadGrid1.DataBind()
End
Sub
Greetings,
Stefan
the Telerik team
Hi
I have same issue when user sort 1 or 2 columns in Radgridview Winform the grid does not return correct value for current row.
I need whenever user scrolling in grid one filed shows in a separate text box but after sorting the grid it does not return right row index
I have same issue when user sort 1 or 2 columns in Radgridview Winform the grid does not return correct value for current row.
I need whenever user scrolling in grid one filed shows in a separate text box but after sorting the grid it does not return right row index
Thank you for writing.
The following article shows why you are not getting the expected index: Rows vs ChildRows.
In addition, you can get the field or the data item directly from the row instance, there is no need to use indexes:
private
void
RadButton1_Click(
object
sender, EventArgs e)
{
Console.WriteLine(radGridView1.CurrentRow.Cells[
"Name"
].Value);
DataRow data = ((DataRowView)radGridView1.CurrentRow.DataBoundItem).Row;
Console.WriteLine(data[
"Name"
]);
}
I hope this will be useful.
Regards,
Dimitar
Telerik