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

Grid Export Error

4 Answers 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Philip Senechal
Top achievements
Rank 1
Philip Senechal asked on 08 Oct 2008, 06:51 PM
I created the following function for my grid that runs on the PreRender event

    Protected Sub RadGrid1_PreRender(ByVal sender As ObjectByVal e As EventArgs) 
        queueFilter = Request.QueryString("queue"
        For Each item As GridDataItem In RadGrid1.MasterTableView.Items 
            Dim TaskID As String = item("TaskID").Text 
            If TaskID = " " Then 
                Dim cell As TableCell = item.Item("ExpandColumn"
                Dim expandCollapseButton As Button = CType(cell.Controls(0), Button) 
                expandCollapseButton.Visible = False 
            ElseIf queueFilter = "My Requests" Then 
                item.Expanded = True 
            End If 
        Next 
    End Sub 

however, this causes a problem when I use the export to Excel feature as I believe it tried to run this code when doing the export.

Is there a way to make sure this code is NOT run during export? I'm looking for something like an IfIsExporting then don't run it, else run it feature. Thanks.

4 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 13 Oct 2008, 11:55 AM
Hi Philip,

Since the control will be exported, most probably, in an event similar to a button click, you can implement a flag there, which would determine whether it is about to be exported or not.
I hope this is a suitable option for you.

All the best,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Philip Senechal
Top achievements
Rank 1
answered on 13 Oct 2008, 04:42 PM
I need to know what that flag is though...Since I don't have the option of turning the pre-render routine on or off in the export routine, I need to put something in the pre-render routine to determine whether or not the grid is in the process of exporting.

What would that look like? What I can evaluate in the pre-render routine to determine if I'm in the middle of exporting the grid or not?

Thanks.
0
Yavor
Telerik team
answered on 16 Oct 2008, 10:06 AM
Hello Philip,

Let us assume that you havfe a button event declared and the Prerender event handler as well:

 protected void Button1_Click(object sender, EventArgs e)  
    {  
 
    }  
    protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
 
    } 

The button click event handler will be raised first. Then, the PreRender event handler. Thus, you can set a flad (e..g. ViewState["shouldDisableCode"]=true) and execute the code only if the flag is true/false.
I hope this suggestion helps.

Best wishes,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Philip Senechal
Top achievements
Rank 1
answered on 16 Oct 2008, 05:06 PM
I see what you're saying now...got it.

okay...problem solved. Thanks!
Tags
Grid
Asked by
Philip Senechal
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Philip Senechal
Top achievements
Rank 1
Share this question
or