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

Radtoolbar in Radgrid

1 Answer 180 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Karl
Top achievements
Rank 1
Karl asked on 22 Mar 2010, 02:09 PM
Hi,
I have radtoolbar positioned in a Radgrid and generally it is functioning fine.

<CommandItemTemplate> 
                    <telerik:RadToolBar ID="RadToolBar1" OnButtonClick="RadToolBar1_ButtonClick" runat="server" OnClientButtonClicking="onToolBarClientButtonClicking">  
                        <Items> 
                        <telerik:RadToolBarButton Text="Add Record" CommandName="InitInsert" ImageUrl="../../_images/icons/mini_icons/add.png"></telerik:RadToolBarButton> 
                            <telerik:RadToolBarButton Text="Edit Record" CommandName="EditSelected" ImageUrl="../../_Images/Icons/mini_icons/page_edit.png"></telerik:RadToolBarButton>                            
                            <telerik:RadToolBarButton Text="Delete Record" CommandName="DeleteSelected" ImageUrl="../../_Images/Icons/mini_icons/page_delete.png"></telerik:RadToolBarButton> 
                            <telerik:RadToolBarButton Text="Refresh Records" CommandName="RebindGrid" ImageUrl="../../_images/icons/mini_icons/arrow_refresh.png"></telerik:RadToolBarButton> 
                            <telerik:RadToolBarButton Text="Export" CommandName="ExportToExcel" ImageUrl="../../_images/icons/mini_icons/page_excel.png"></telerik:RadToolBarButton> 
                        </Items> 
                    </telerik:RadToolBar> 
</CommandItemTemplate> 

 

However, I jave 2 questions;

1) Is it possible to disable the toolbar when a user is adding or editing a record

2) Can i disable Ajax just on the click of the Export button in the toolbar. I have been able to disable Ajax for the whole toolbar, but I would like to disable it just for one of the buttons within the toolbar i.e The export button.

 

Thanks a lot.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Mar 2010, 07:25 AM

Hello Karl,

1. Try the following code snippet in order to disable the radtoolbar when grid in edit/insert mode.

C#:

 
    protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        GridCommandItem cmdItem = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0];  
        RadToolBar toolBar = (RadToolBar)cmdItem.FindControl("RadToolBar1");  
        if (RadGrid1.EditIndexes.Count > 0 || RadGrid1.MasterTableView.IsItemInserted)  
        {          
            toolBar.Enabled = false;  
        }  
        else  
        {  
            toolBar.Enabled = true;  
        }  
    } 

I tried following settings for RadToolBar.

 
    <CommandItemTemplate>  
        <telerik:RadToolBar ID="RadToolBar1" runat="server" AutoPostBack="true">  
            <Items>  
             . . .  
            </Items>  
        </telerik:RadToolBar>  
    </CommandItemTemplate> 

2. For disabling ajax for particular button, use the set_enableAjax() property of RadAjaxManager Client Object.

Please go throught the documentation which might help in this: Export from ajaxified grid

-Shinu.

Tags
Grid
Asked by
Karl
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or