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

complete postback inside ajaxed radgrid

8 Answers 320 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Avi
Top achievements
Rank 1
Avi asked on 21 Jun 2010, 02:54 PM
Hi,
I have ajaxed radgrid component (with EditFormSettings) that need to postback on specific case.
The radgrid contains GridButtonColumn object when clicked it creates excel file and send it through httpresponse.
I thought I solve the problem by register the buttons at radgrid ItemCreated event
this is the code:

    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        //register all buttons that exports excel files 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem gridItem = e.Item as GridDataItem; 
            try 
            { 
                TableCell buttonTc = gridItem["exportButton"]; 
                ControlCollection controls = buttonTc.Controls; 
                foreach (Control button in controls) 
                { 
                    ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(button); 
                } 
            } 
            catch (Exception) { return; } 
        } 
    }  

it works perfectly till someone opens the EditFormSettings (by clicking on a row).
after that, it looks like the buttons were somehow unregistered and became ajax again, which means no excel file will open.

Is there a solution for this?

thanks.

8 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Jun 2010, 03:14 PM
Hello,

The following documentation explains how to perform postback for ajaxified controls. I hope that will help you.
Forcing postback

Thanks,
Princy.
0
Avi
Top achievements
Rank 1
answered on 22 Jun 2010, 08:01 AM
Thanks Princy,
But It didn't help me (maybe if you can elaborate).

I don't understand why after the user fires an ajax event inside the grid, the buttons becomes ajax instead of postback...?


thanks

0
Veli
Telerik team
answered on 24 Jun 2010, 03:21 PM
Hello Avi,

If you have export buttons in your edit form that need to postback, you need to also find these buttons using ItemCreated and register them as postback controls:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    //register all buttons that exports excel files
    if (e.Item is GridEditableItem)
    {
        GridEditableItem gridItem = e.Item as GridEditableItem;
        try
        {
            TableCell buttonTc = gridItem["exportButton"];
            ControlCollection controls = buttonTc.Controls;
            foreach (Control button in controls)
            {
                ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(button);
            }
        }
        catch (Exception) { return; }
    }
}

The difference between the above snippet and your piece of code is that we check for GridEditableItem which also includes the edit forms. We thus find export buttons in the edit form too.

If this is not the case with your scenario, consider removing the try - catch block to see if you get any exceptions and if they don't tell you something related to this issue.

Best wishes,
Veli
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
0
Avi
Top achievements
Rank 1
answered on 27 Jun 2010, 07:40 AM
Thank you Veli,
My issue is not inside the edit form, the buttons that needs to be postback are the GridButtonColumn which belongs to the RadGrid.
This is my RadGrid, the last column, exportButton, is the one I have trouble convert to full post back.
        <telerik:RadGrid ID="activityRadGrid" runat="server" width="100%" GridLines="None" 
            PageSize="10" AllowPaging="True" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" 
            OnItemCommand="activityRadGrid_itemCommand" OnItemCreated="RadGrid1_ItemCreated" 
            OnItemDataBound="activityRadGrid_ItemDataBound" 
            AllowMultiRowSelection="false" AllowFilteringByColumn="True"
            <PagerStyle Mode="NextPrevNumericAndAdvanced" /> 
            <SelectedItemStyle BackColor="#f6faf9" /> 
            <MasterTableView Name="masterTableView" Dir="RTL" GroupLoadMode="Server" 
                DataKeyNames="ID" DataSourceID="SqlDataSource1" 
                AllowSorting="true" AllowMultiColumnSorting="true" TableLayout="Auto"
                <HeaderStyle HorizontalAlign="Center" BorderStyle="Groove"/> 
                <ItemStyle HorizontalAlign="Center" /> 
                <Columns> 
                    <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" EditText="פתח" Visible="false"
                    </telerik:GridEditCommandColumn> 
                    <telerik:GridBoundColumn DataField="ID" HeaderText="ID" UniqueName="ID" Visible="false" > 
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="source" HeaderText="source" UniqueName="source" Visible="false" > 
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="source_heb" HeaderText="מקור נתונים" UniqueName="source_heb" ItemStyle-HorizontalAlign="Right" > 
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="job_id" HeaderText="מס' תהליך" UniqueName="job_id" FilterControlWidth="30px"
                    </telerik:GridBoundColumn> 
                    <telerik:GridDateTimeColumn DataField="MATCHER_LAST_END_DATE" HeaderText="תאריך סיום הצלבה" UniqueName="MATCHER_LAST_END_DATE" 
                                             DataFormatString="{0:dd/MM/yy}" PickerType="DatePicker"
                        <HeaderStyle Width="120px" /> 
                    </telerik:GridDateTimeColumn> 
                    <telerik:GridBoundColumn DataField="MATCHER_ACCUM_RECORDS" HeaderText="סהכ רשומות שעברו הצלבה" AllowFiltering="false" 
                                             UniqueName="MATCHER_ACCUM_RECORDS"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="ACTIVITY_ACCUM_NUMOFDICOVERY" HeaderText="סהכ גילויים שנוצרו" UniqueName="ACTIVITY_ACCUM_NUMOFDICOVERY" AllowFiltering="false"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="ACTIVITY_ACCUM_NUMOFRECLAMTION" HeaderText="סהכ טיובים שנוצרו" AllowFiltering="false" 
                                             UniqueName="ACTIVITY_ACCUM_NUMOFRECLAMTION"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="ACTIVITY_STATUS" HeaderText="סטטוס פעילות" ItemStyle-Width="15px" AllowFiltering="false" 
                                             UniqueName="ACTIVITY_STATUS"
                    </telerik:GridBoundColumn> 
                    <telerik:GridButtonColumn Text="צור קובץ" headerText="תוצאות הצלבה" HeaderButtonType="LinkButton" UniqueName="exportButton"  
                                              CommandName="Export"
                    </telerik:GridButtonColumn> 
                </Columns> 
                <EditFormSettings UserControlName="controls\ActivityInnerControl.ascx" EditFormType="WebUserControl"
                    <EditColumn UniqueName="EditCommandColumn1"
                    </EditColumn> 
                </EditFormSettings> 
            </MasterTableView> 
            <EditItemStyle BackColor="#e8f1f0" BorderStyle="Double"></EditItemStyle> 
            <SelectedItemStyle BorderStyle="None"></SelectedItemStyle>  
            <ClientSettings> 
                <ClientEvents OnRowClick="RowDblClick" /> 
            </ClientSettings> 
            <GroupingSettings GroupByFieldsSeparator="Status_text" ShowUnGroupButton="true"/> 
        </telerik:RadGrid> 
 

Thanks again.

0
Veli
Telerik team
answered on 28 Jun 2010, 02:35 PM
Hello Avi,

Sorry for misunderstanding you, then. The scenario that you describe to be using seems to work OK at my side, though. Attaching a test page you can run locally too. I find the export button in the export column and register it as a postback control through the ScriptManager.

Greetings,
Veli
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
0
Avi
Top achievements
Rank 1
answered on 23 Aug 2010, 09:30 AM
Many thanks Veli, it's working now :)

(Sometimes I feel like running around in circles,
I wasn't thinking ahead, Now that they are standard buttons, I wont see the "Loading" logo :( )


0
Steve
Top achievements
Rank 1
answered on 13 Mar 2020, 06:15 PM

Hello Veli,

This fixed it for me as well. 

After I modified my datasource, the grid refreshed as expected, but the export button quit working again (parsing error). So initial loading of the radGrid was okay, but refreshing radGrid data killed it. I even noticed the ITemCreated event fired again to register postback.

Thanks for any feedback.
Steve


    protected void RadGridTR_List_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                ImageButton exportButton = (ImageButton)item["Download"].Controls[0];
                ScriptManager.GetCurrent(Page).RegisterPostBackControl(exportButton);
            }
        }
    }

0
Eyup
Telerik team
answered on 18 Mar 2020, 03:59 PM

Hi Steve,

 

Thanks for sharing your experience with our community.

You can also check the javascript approach provided here:

https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/how-to/Exporting/export-from-ajaxified-grid#export-from-ajaxified-grid

 

Regards,
Eyup
Progress Telerik

Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
Tags
Grid
Asked by
Avi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Avi
Top achievements
Rank 1
Veli
Telerik team
Steve
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or