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

Disable Detail Table

3 Answers 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lynda Golomb
Top achievements
Rank 1
Lynda Golomb asked on 29 Dec 2009, 02:42 PM
Hi,
I have a grid with 3 detail tables on the same level. I need to disable the entire grid in such a way that the user will be able to open the lower tables to view the data but not change it (this needs to be done through code).
Would appreciate any help.
Thanks,
Lynda

<telerik:RadGrid ID="RadGridCV" runat="server" Skin="Office2007" GridLines="None" Width="98%" AllowMultiRowSelection="True" AllowMultiRowEdit="True">  
<MasterTableView AutoGenerateColumns="False" DataKeyNames="Person_Id" Width="100%" EditMode="InPlace">  
    <Columns> 
        <telerik:GridBoundColumn DataField="Person_Id" SortExpression="Person_Id" ReadOnly="True" UniqueName="Person_Id" Visible="False"></telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="Person_FirstNameEng" HeaderText="First Name" ReadOnly="True" SortExpression="Person_FirstNameEng" UniqueName="Person_FirstNameEng">  
            <ItemStyle VerticalAlign="Top" /> 
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="Person_LastNameEng" HeaderText="Last Name" ReadOnly="True" SortExpression="Person_LastNameEng" UniqueName="Person_LastNameEng">  
            <ItemStyle VerticalAlign="Top" /> 
        </telerik:GridBoundColumn> 
        <telerik:GridTemplateColumn UniqueName="ListOfPublicationsFile" HeaderText="List Of Publications File" DefaultInsertValue="">          
            <ItemTemplate>    
             <asp:Label ID="Label1" runat="server" Text='<%#Bind("ListOfPublicationsFile") %>'></asp:Label>    
            </ItemTemplate>   
            <EditItemTemplate><asp:FileUpload ID="FileUploadListOfPublications" runat="server" /></EditItemTemplate>    
            <ItemStyle VerticalAlign="Top" /> 
        </telerik:GridTemplateColumn>   
        <telerik:GridEditCommandColumn><ItemStyle ForeColor="Green" VerticalAlign="Top" /></telerik:GridEditCommandColumn> 
    </Columns> 
      
    <DetailTables> 
     <telerik:GridTableView Enabled="false" Name="AcademiclBackground" EditMode="InPlace" CommandItemDisplay="Bottom" runat="server" Caption="A. Academic Background" Width="100%" AutoGenerateColumns="False" DataKeyNames="ACBG_ItemNum">  
       <ParentTableRelation> 
         <telerik:GridRelationFields   
           DetailKeyField="ACBG_PersonId" 
           MasterKeyField="Person_Id" /> 
       </ParentTableRelation> 
       <Columns> 
           <telerik:GridBoundColumn DataField="ACBG_OrderBy" ColumnEditorID="myTextBoxEditor30px" HeaderText="Row No." SortExpression="ACBG_OrderBy" UniqueName="ACBG_OrderBy">  
               <ItemStyle Width="30px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="ACBG_FromTo" ColumnEditorID="myTextBoxEditor70px" HeaderText="Date From To" SortExpression="ACBG_FromTo" UniqueName="ACBG_FromTo">  
               <ItemStyle Width="80px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="ACBG_Institute" ColumnEditorID="myTextBoxEditor130px" HeaderText="Institute" SortExpression="ACBG_Institute" UniqueName="ACBG_Institute">  
               <ItemStyle Width="150px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="ACBG_Degree" ColumnEditorID="myTextBoxEditor50px" HeaderText="Degree" SortExpression="ACBG_Degree" UniqueName="ACBG_Degree">  
               <ItemStyle Width="60px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="ACBG_Area" ColumnEditorID="myTextBoxEditor100px" HeaderText="Area" SortExpression="ACBG_Area" UniqueName="ACBG_Area">  
               <ItemStyle Width="120px" /> 
           </telerik:GridBoundColumn>   
           <telerik:GridEditCommandColumn ButtonType="ImageButton" CancelImageUrl="~/Images/cancel.gif" 
               EditImageUrl="~/Images/edit.gif" InsertImageUrl="~/Images/update.gif" UpdateImageUrl="~/Images/update.gif"><ItemStyle  ForeColor="#007E00" /></telerik:GridEditCommandColumn> 
           <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="column" ButtonType="ImageButton" ImageUrl="~/Images/delete.gif"><ItemStyle ForeColor="#E40000" /></telerik:GridButtonColumn> 
       </Columns> 
       <CommandItemSettings AddNewRecordText="Add Academic Background Item" /> 
         <EditFormSettings><EditColumn UniqueName="EditCommandColumn1"></EditColumn></EditFormSettings>  
     </telerik:GridTableView> 
       
     <telerik:GridTableView Name="PreviousEmployment" EditMode="InPlace" CommandItemDisplay="Bottom" runat="server" Caption="B. Previous Employment&lt;br/&gt;&lt;span class=HeaderText&gt;Begin with present position (do not include tutoring, memberships in scientific associations or guest lectures)&lt;/span&gt;" Width="100%" AutoGenerateColumns="False" DataKeyNames="PE_ItemNum" AllowPaging="True">  
       <ParentTableRelation> 
         <telerik:GridRelationFields   
           DetailKeyField="PE_PersonId" 
           MasterKeyField="Person_Id" /> 
       </ParentTableRelation> 
       <Columns> 
           <telerik:GridBoundColumn DataField="PE_OrderBy" ColumnEditorID="myTextBoxEditor30px"  HeaderText="Row No." SortExpression="PE_OrderBy" UniqueName="PE_OrderBy">  
               <ItemStyle Width="30px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="PE_FromTo" ColumnEditorID="myTextBoxEditor70px" HeaderText="Date From To" SortExpression="PE_FromTo" UniqueName="PE_FromTo">  
               <ItemStyle Width="80px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="PE_Institute" ColumnEditorID="myTextBoxEditor130px" HeaderText="Institute" SortExpression="PE_Institute" UniqueName="PE_Institute">  
               <ItemStyle Width="150px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="PE_Title" ColumnEditorID="myTextBoxEditor50px" HeaderText="Title" SortExpression="PE_Title" UniqueName="PE_Title">  
               <ItemStyle Width="60px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="PE_Area" ColumnEditorID="myTextBoxEditor100px" HeaderText="Research Area" SortExpression="PE_Area" UniqueName="PE_Area">  
               <ItemStyle Width="120px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridEditCommandColumn ButtonType="ImageButton" CancelImageUrl="~/Images/cancel.gif" EditImageUrl="~/Images/edit.gif" InsertImageUrl="~/Images/update.gif" UpdateImageUrl="~/Images/update.gif"><ItemStyle ForeColor="#007E00" /></telerik:GridEditCommandColumn> 
           <telerik:GridButtonColumn CommandName="Delete" UniqueName="column" ButtonType="ImageButton" ImageUrl="~/Images/delete.gif"><ItemStyle ForeColor="#E40000" /></telerik:GridButtonColumn> 
       </Columns> 
       <CommandItemSettings AddNewRecordText="Add Previous Employment Item" /> 
         <EditFormSettings> 
             <EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
         </EditFormSettings> 
     </telerik:GridTableView> 
       
     <telerik:GridTableView Name="GrantsAndAwards" CommandItemDisplay="Bottom" runat="server" Caption="C. Grants and Awards Received Within the Past Five Years&lt;br/&gt;&lt;span class=HeaderText&gt;Please indicate the date of receiving the grant/award and the funding period in the comments box.&lt;/span&gt;" Width="100%" AutoGenerateColumns="False" DataKeyNames="GAA_Id" AllowPaging="True">  
       <ParentTableRelation> 
         <telerik:GridRelationFields   
           DetailKeyField="GAA_PersonId" 
           MasterKeyField="Person_Id" /> 
       </ParentTableRelation> 
       <Columns> 
           <telerik:GridBoundColumn DataField="GAA_OrderBy"  HeaderText="Row No." SortExpression="GAA_OrderBy" UniqueName="GAA_OrderBy">  
               <ItemStyle Width="30px" /> 
           </telerik:GridBoundColumn>   
           <telerik:GridBoundColumn DataField="GAA_ResearchTopics"  HeaderText="Research Topics" SortExpression="GAA_ResearchTopics" UniqueName="GAA_ResearchTopics">  
               <ItemStyle Width="200px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="GAA_FundingAgency" HeaderText="Funding Organization" SortExpression="GAA_FundingAgency" UniqueName="GAA_FundingAgency">  
               <ItemStyle Width="150px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="GAA_TotalGrant" HeaderText="Total (in $)" SortExpression="GAA_TotalGrant" UniqueName="GAA_TotalGrant">  
               <HeaderStyle Wrap="False" /> 
               <ItemStyle Wrap="False" Width="60px" /> 
           </telerik:GridBoundColumn>    
           <telerik:GridEditCommandColumn ButtonType="ImageButton" CancelImageUrl="~/Images/cancel.gif" EditImageUrl="~/Images/edit.gif" InsertImageUrl="~/Images/update.gif" UpdateImageUrl="~/Images/update.gif"><ItemStyle ForeColor="#007E00" /></telerik:GridEditCommandColumn> 
           <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="column" ButtonType="ImageButton" ImageUrl="~/Images/delete.gif"><ItemStyle ForeColor="#E40000" /></telerik:GridButtonColumn> 
       </Columns> 
       <CommandItemSettings AddNewRecordText="Add Grant and Award Item" /> 
        <EditFormSettings UserControlName="~/Controls/ucGrantsAndAwardsDetails.ascx" EditFormType="WebUserControl"><EditColumn UniqueName="EditCommandColumn1"></EditColumn></EditFormSettings>  
     </telerik:GridTableView> 
 
</DetailTables> 
    <ExpandCollapseColumn Visible="True"></ExpandCollapseColumn> 
    <EditFormSettings> 
        <EditColumn UniqueName="EditCommandColumn1">  
        </EditColumn> 
    </EditFormSettings> 
</MasterTableView> 
</telerik:RadGrid> 

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 29 Dec 2009, 03:50 PM
Hello Lynda,

Since it is not an easy task to disable the whole RadGrid in such way, you can disable only the Edit / Add New Item buttons if this approach is suitable for your scenario..
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item.OwnerTableView.Name != "something")
    {
        if (e.Item is GridDataItem)
            (e.Item as GridDataItem)["AutoGeneratedEditColumn"].Enabled = false;
        if (e.Item is GridCommandItem)
            (e.Item.FindControl("InitInsertButton").Parent as TableCell).Enabled = false;
    }
}

Enabled/Disabled conventions

I hope this helps.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Lynda Golomb
Top achievements
Rank 1
answered on 29 Dec 2009, 04:52 PM
That works very well for me, thankyou.
Can I ask also how to remove the 'Refersh' button?
0
Daniel
Telerik team
answered on 29 Dec 2009, 05:12 PM
Hello Lynda,

Whether you will disable or remove (hide) the control depends only on the property you use - Enabled or Visible:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item.OwnerTableView.Name != "something")
    {
        if (e.Item is GridCommandItem)
            (e.Item.FindControl("RefreshButton").Parent as TableCell).Enabled = false;
    }
}

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Lynda Golomb
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Lynda Golomb
Top achievements
Rank 1
Share this question
or