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

Export of RadGrid with updatepanel and "UseStaticHeader"

3 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rudy
Top achievements
Rank 1
Rudy asked on 27 May 2013, 09:25 AM
Hi,
I have a problem that when i use the staticheaders option of the RadGrid, my export does not work. Only the first time.
The RadGrid exists in an updatepanel. I have registered the exelbutton as postbackcontrol to the scriptmanager.

In the ItemCreated eventhandler of the radgrid
System.Web.UI.Control ctrl = e.Item.FindControl("ExportToExcelButton");
System.Web.UI.ScriptManager.GetCurrent(grid.Page).RegisterPostBackControl(ctrl);

So when usestaticheaders = false, export works, when true not !

There is an old post where you mentioned the usestaticheaders should be set to false when exporting, is this still relevant or not?
The post:
http://www.telerik.com/community/forums/aspnet-ajax/grid/export-grid-within-updatepanel.aspx

I also tried it adding following function, but in our application it does not work, only the first option, (register as portbackbutton)

Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(initializeRequestHandler);
 
function initializeRequestHandler(sender, args)
{
   if (args.get_postBackElement().id.indexOf("ExportToExcelButton") != -1)
   {
      args.set_cancel(true);
      sender._form["__EVENTTARGET"].value =
      args.get_postBackElement().id.replace(/\_/g, "$");
      sender._form["__EVENTARGUMENT"].value = "";
      sender._form.submit()
   }
}

Thanks in advance
Rudy

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 30 May 2013, 06:44 AM
Hello Rudy,

You have to disable the static header in order the export functionality to work properly. A possible solution to achieve that is to hook on button click event handler and disable it in your code behind. Check out the following code snippet.
protected void Button1_Click(object sender, EventArgs e)
{
    RadGrid1.ClientSettings.Scrolling.UseStaticHeaders = false;
    RadGrid1.MasterTableView.ExportToExcel();
}

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Rudy
Top achievements
Rank 1
answered on 30 May 2013, 07:21 AM
Hi Kostadin,
I could do that, but apparently in the Pre_Render of the page the UseStaticHeaders property is auto magicly set to false without any intervention on my side.

In the designer this property is set to True, when i click the export and set the debugger to the Pre_Render the UseStaticHeaders is set to false.
protected override void OnPreRender(EventArgs e)
{
   var before = this.RadGrid1.ClientSettings.Scrolling.UseStaticHeaders; // before is true
    base.OnPreRender(e);
    var after = this.RadGrid1.ClientSettings.Scrolling.UseStaticHeaders; // after is false
}

 

But when i have paging enabled, and change the index, click the export, "UseStaticHeaders" is ignored. What i mean is that i have to scroll again to see the pager, and then when i change the pageindex, the "UseStaticHeaders" is false. Resulting in unwanted behaviour.

protected void OnPageSizeChanged(object sender, EventArgs e)
{
   var check = this.RadGrid1.ClientSettings.Scrolling.UseStaticHeaders; // check is false
}

Kr,
Rudy

 

0
Kostadin
Telerik team
answered on 03 Jun 2013, 01:36 PM
Hi Rudy,

I was not able to replicate the issue. I prepared a small sample and attached it to this forum post. Please give it a try and let me know how it differs form your real setup.

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Rudy
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Rudy
Top achievements
Rank 1
Share this question
or