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

Make field enterable in Hierachy PopUp

3 Answers 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric Turner
Top achievements
Rank 1
Eric Turner asked on 14 Apr 2010, 04:57 PM
I need to disable and enable a field in a popup edit form depending on edit or insert mode.  The grid has a MasterTableView and One Detail Table.  When I expand the MasterTableView, the Detail Table has a command Item Insert link along with edit and delete buttons.  I tried to do this in the RadGrid1_ItemCommand routine when the command is "InitInsert" but I cannot get a handle on the field I need.  How can I do this?

protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
        { 
            if ("Detail".Equals(e.Item.OwnerTableView.Name)) 
            { 
                 
                if ("InitInsert".Equals(e.CommandName)) 
                {                     
                    (e.Item as GridEditableItem)["PackageName"].Enabled = true
                }                 
            } 
        } 



        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1"  
            GridLines="None"  AutoGenerateColumns="False"  
             OnInsertCommand="RadGrid1_InsertCommand" 
             OnItemUpdate="RadGrid1_UpdateCommand"  
             OnItemCommand="RadGrid1_ItemCommand"
<HeaderContextMenu EnableTheming="True"
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
</HeaderContextMenu> 
 
<MasterTableView datasourceid="SqlDataSource1" DataKeyNames="Group_Name"  
                AllowFilteringByColumn="True"  Name="Header"
    <DetailTables> 
        <telerik:GridTableView runat="server" DataSourceID="SqlDataSource2" 
             DataKeyNames="Group_Name" CommandItemDisplay="Top" Name="Detail"  
            AllowAutomaticUpdates="False" EditMode="PopUp"
            <ParentTableRelation> 
               <telerik:GridRelationFields DetailKeyField="Group_Name" MasterKeyField="Group_Name" /> 
            </ParentTableRelation>   
            <CommandItemSettings AddNewRecordImageUrl="\Images\AddRecord.gif" /> 
            <RowIndicatorColumn> 
                <HeaderStyle Width="20px" /> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn> 
                <HeaderStyle Width="20px" /> 
            </ExpandCollapseColumn> 
            <Columns> 
                <telerik:GridEditCommandColumn> 
                </telerik:GridEditCommandColumn> 
                <telerik:GridButtonColumn CommandName="Delete" Text="Delete"  
                    UniqueName="column3"
                </telerik:GridButtonColumn> 
                <telerik:GridBoundColumn DataField="Package_Name" UniqueName="PackageName" HeaderText="Package Name"  
                    Visible="True" ReadOnly="True"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Group_Name" UniqueName="column2"  
                    Visible="False" Display="False" ReadOnly="True"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="ConnectionString"  
                    UniqueName="ConnectionString" HeaderText="Connection String"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="FileId" UniqueName="FileId" Visible="False"  
                    Display="False" ReadOnly="True"
                </telerik:GridBoundColumn> 
                <telerik:GridDropDownColumn DataField="Active" ForceExtractValue="InEditMode"  
                    HeaderText="Active" UniqueName="Active" DataSourceID="SqlDataSource3" ListTextField="Active"  
                    ListValueField="Active"
                </telerik:GridDropDownColumn> 
                <telerik:GridDropDownColumn DataField="InProcess" ForceExtractValue="InEditMode"  
                    HeaderText="In Process" UniqueName="InProcess" DataSourceID="SqlDataSource3" ListTextField="Active"  
                    ListValueField="Active"
                </telerik:GridDropDownColumn> 
            </Columns> 
            <EditFormSettings CaptionFormatString="test"
                <EditColumn UniqueName="EditCommandColumn1"
                </EditColumn> 
            </EditFormSettings> 
        </telerik:GridTableView> 
    </DetailTables> 
    <ParentTableRelation> 
        <telerik:GridRelationFields DetailKeyField="Group_Name" /> 
    </ParentTableRelation> 
<RowIndicatorColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</RowIndicatorColumn> 
 
<ExpandCollapseColumn visible="True"
<HeaderStyle Width="20px"></HeaderStyle> 
</ExpandCollapseColumn> 
    <Columns> 
        <telerik:GridBoundColumn DataField="Application_Name" UniqueName="column1"  
            HeaderText="Application Name"
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="Group_Name" UniqueName="Group_Name"  
            HeaderText="Group Name"
        </telerik:GridBoundColumn> 
    </Columns> 
</MasterTableView> 
 
<FilterMenu EnableTheming="True"
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
</FilterMenu> 
        </telerik:RadGrid> 

3 Answers, 1 is accepted

Sort by
0
Eric Turner
Top achievements
Rank 1
answered on 16 Apr 2010, 09:13 PM
let me ask this another way.  I have an hierarchical grid that has an insert link on the detail gridview.  When I click the insert link I have editing set as "popup".  There are certain fields that show on the grid that do not show in the popup but do show in the grid because the readonly property is true. I want to change the readonly property to false in this instance but leave it false when going into edit mode. Everyway I have tried to do this throws a null reference error..Can anyone help a rookie?
0
Accepted
Martin
Telerik team
answered on 19 Apr 2010, 07:48 AM
Hello Eric Turner,

I would suggest that you review the following help article:

Different edit/insert forms with auto-generated edit form

You might need to modify the code to ensure that your logic is applied to the detail table only.

I hope this helps,
Martin
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
Eric Turner
Top achievements
Rank 1
answered on 19 Apr 2010, 01:11 PM
Perfect!  that solved it.
Tags
Grid
Asked by
Eric Turner
Top achievements
Rank 1
Answers by
Eric Turner
Top achievements
Rank 1
Martin
Telerik team
Share this question
or