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

[Solved] Extending Export

3 Answers 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ross
Top achievements
Rank 1
Ross asked on 28 Apr 2009, 09:52 AM
I need to export my own propriatory xml format based on the dataitems of the grid.  This would be easy enough by simply iterating through the grid items, however the export functonality has some nice features, such as being able to ignore paging (by returning all items from the datasource).

So... is there any way to extend the grids export functionality?

If the answer to the above is no, then what is the best way to return all the dataitems from a grid (which ignores paging, but will honor any filters or sorting that have been applied)?

Thanks.

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 29 Apr 2009, 02:13 PM
Hi Ross,

You can get the raw html of the grid, just attach a render delegate to the grid object and use its RenderControl method as follows:

C#
string GridRawHtml;     
         
    protected void Page_Load(object sender, EventArgs e)     
    {     
        RadGrid1.SetRenderMethodDelegate(new RenderMethod(GetHtml));             
    }     
    
    protected void GetHtml(HtmlTextWriter writer, Control c)     
    {     
        StringWriter stringWriter = new StringWriter();     
        HtmlTextWriter clearWriter = new HtmlTextWriter(stringWriter);     
        RadGrid1.MasterTableView.RenderControl(clearWriter);     
        string GridRawHtml = clearWriter.InnerWriter.ToString();     
    } 

I hope this suggestion will help you on the right track with your implementation.

All the best,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ross
Top achievements
Rank 1
answered on 29 Apr 2009, 03:24 PM
Hi,

That is useful, but it won't solve the problem when I need to ignore paging.  The grids native export method calls several internal methods to make this possible which I can't call or override... to be clear on what I need to do...

1) User opens page with a grid of results, they filter them, sort, page through them as required
2) User clicks an export button, which needs to grab the grid data (not just those rows which are visiible, but all rows, including those on other pages).

An easy option would be to simply re-query my datasource, but I want the grid to do the work, maintaining any filters, sort orders etc.

0
Pavlina
Telerik team
answered on 30 Apr 2009, 04:21 PM
Hi Ross,

To return all the dataitems from a grid you need to set the IgnorePaging property to true.
In your case instead of RadGrid1.ExportSettings.IgnorePaging = true I suggest that you use the code snippet bellow:
 

C#
 RadGrid1.AllowPaging = false;     
    RadGrid1.Rebind(); 

Please give this suggestion a try and let us know how it goes.

Kind regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Ross
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Ross
Top achievements
Rank 1
Share this question
or