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

Export row to csv using ItemCommand

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
w3stfa11
Top achievements
Rank 1
w3stfa11 asked on 31 Aug 2010, 08:26 PM
I have a grid with at most 10 rows. Each has a button (buttoncolumn) that will export that row's fields to CSV. I'm unable to export only the row when I click the button. It exports all the rows. I tried hiding the other rows but it didn't work.



protected void rgridAdp_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "Export")
            {
                GridDataItem dataItem = e.Item as GridDataItem;
                int batchId = StringHandlers.GetSafeInteger(dataItem["BatchNumber"].Text);
foreach (GridDataItem item in rgridAdp.MasterTableView.Items)
                    {
                        if (StringHandlers.GetSafeInteger(item["BatchNumber"].Text) == batchId)
                        {
                            item.Visible = true;
                            item.Display = true;
                        }
                        else
                        {
                            item.Display = false;
                            item.Visible = false;
                        }
                    }
                    rgridAdp.ExportSettings.FileName = "ADPExport-" + batchId;
                    rgridAdp.ExportSettings.ExportOnlyData = true;
 
                    rgridAdp.ExportSettings.OpenInNewWindow = true;
                    rgridAdp.MasterTableView.GetColumn("Export").Visible = false; // don't export button
                    rgridAdp.MasterTableView.ExportToCSV();

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 03 Sep 2010, 11:07 AM
Hello w3stfa11,

I attached a runnable demo to this post. Let me know whether the demonstrated approach is suitable for you.

Regards,
Daniel
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
Tags
Grid
Asked by
w3stfa11
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or