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

Modify Popup form on new item insert

1 Answer 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Geo
Top achievements
Rank 1
Geo asked on 11 Jan 2019, 10:17 PM

Hello, I have the following requirements for enhancing a radgrid on a page on our website:

 

1. When the insert form is opened, the end user should only see the Date of Service and Status fields enabled.

2. Upon selecting a status, the other elements in the form should be updated based on the selected status

 

Here is how we have our radgrid set up in the aspx page:

 

<telerik:RadGrid ID="RadGrid2" ShowStatusBar="True" runat="server" AllowPaging="True" PageSize="5" DataSourceID="SqlDataSource2" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" ShowFooter="True" Skin="Silk" ShowHeader="False" AllowSorting="True">
        <MasterTableView Width="100%" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" CommandItemDisplay="Top" ShowFooter="False" EditMode="PopUp" DataKeyNames="VisitsID" ShowHeader="True" InsertItemPageIndexAction="ShowItemOnCurrentPage">
            <EditFormSettings PopUpSettings-Height="400px" PopUpSettings-Width="810px">
                <EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn column"/>
                <PopUpSettings Modal="True" Height="400px" Width="810px" ScrollBars="Vertical"/>
            </EditFormSettings>          
 
            <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Add new visit"/>
            <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"/>
            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"/>
      
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                    <ItemStyle CssClass="MyImageButton" />
                </telerik:GridEditCommandColumn>        
                 
                <telerik:GridBoundColumn DataField="ClaimsID" DataType="System.Int32" FilterControlAltText="Filter ClaimsID column" HeaderText="ClaimsID" ReadOnly="True" SortExpression="ClaimsID" UniqueName="ClaimsID" Visible="False"/>               
                <telerik:GridBoundColumn DataField="FirstName" FilterControlAltText="Filter FirstName column" HeaderText="Name" SortExpression="FirstName" UniqueName="FirstName" ReadOnly="True"/>               
                <telerik:GridDateTimeColumn DataField="DOS" FilterControlAltText="Filter DOS column" HeaderText="DOS" SortExpression="DOS" DataFormatString = "{0:d}" UniqueName="DOS" DataType="System.DateTime">
                    <ColumnValidationSettings EnableRequiredFieldValidation="True">
                        <RequiredFieldValidator Display="Dynamic" ErrorMessage="DOS is Required!" Font-Bold="True" ForeColor="Red" SetFocusOnError="True"/>
                    </ColumnValidationSettings>
               </telerik:GridDateTimeColumn>               
                
               <telerik:GridDropDownColumn DataSourceID="SqlDataSource4" ListTextField="Units" ListValueField="Units" UniqueName="Units" SortExpression="Units" HeaderText="Units" DataField="Units" DropDownControlType="RadComboBox" FooterText="RadComboBox column footer" AllowAutomaticLoadOnDemand="false" AllowVirtualScrolling="true" ShowMoreResultsBox="true" ItemsPerRequest="10"/>              
               <telerik:GridDropDownColumn DataSourceID="SqlDataSource6"  ListTextField="DDDDescription" ListValueField="DDDCode" FilterControlAltText="Filter DDDCode column" HeaderText="Code" DataField="DDDCode" SortExpression="DDDCode" UniqueName="DDDCode" DropDownControlType="RadComboBox"  FooterText="RadComboBox column footer" AllowAutomaticLoadOnDemand="false" AllowVirtualScrolling="true" ShowMoreResultsBox="true" ItemsPerRequest="10"/>              
               <telerik:GridDropDownColumn DataSourceID="SqlDataSource7"  ListTextField="VisitStatus" ListValueField="VisitStatus" FilterControlAltText="Filter Status column" HeaderText="Status" DataField="VisitStatus" SortExpression="VisitStatus" UniqueName="VisitStatus" DropDownControlType="RadComboBox"  FooterText="RadComboBox column footer" AllowAutomaticLoadOnDemand="false" AllowVirtualScrolling="true" ShowMoreResultsBox="true" ItemsPerRequest="10"/>              
               <telerik:GridBoundColumn DataField="TherapistID" FilterControlAltText="Filter TherapistID column" HeaderText="TherapistID" SortExpression="TherapistID" UniqueName="TherapistID" Visible="False"/>              
               <telerik:GridBoundColumn DataField="PatientID" FilterControlAltText="Filter PatientID column" HeaderText="PatientID" SortExpression="PatientID" UniqueName="PatientID" DataType="System.Int32" Visible="False"/>              
               <telerik:GridTemplateColumn HeaderText="Subjective" UniqueName="Subjective">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Subjective") %>' TextMode="MultiLine" Height="70px" Width="700px" Wrap="True"/>
                        <asp:CustomValidator id="custV" runat="server" ControlToValidate = "TextBox1" ErrorMessage = "Minimum of 25 characters required" ClientValidationFunction="MinLength"/>
                        <asp:RequiredFieldValidator id="RequiredFieldValidator1" ControlToValidate="TextBox1" Text="Subjective Is Required" runat="server"/>
                     </EditItemTemplate>
 
                     <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("Subjective") %>'/>
                     </ItemTemplate>                  
                </telerik:GridTemplateColumn>
                 
                <telerik:GridTemplateColumn HeaderText="Objective" UniqueName="Objective" >
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Objective") %>' TextMode="MultiLine" Height="70px" Width="700px"/>
                        <asp:CustomValidator id="custV2" runat="server" ControlToValidate = "TextBox2" ErrorMessage = "Minimum of 25 characters required" ClientValidationFunction="MinLength"/>
                        <asp:RequiredFieldValidator id="RequiredFieldValidator2" ControlToValidate="TextBox2" Text="Objective Is Required" runat="server"/>
                     </EditItemTemplate>
                      
                     <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Eval("Objective") %>'/>
                     </ItemTemplate>                      
                </telerik:GridTemplateColumn>               
 
                <telerik:GridTemplateColumn HeaderText="Assessment" UniqueName="Assessment" >
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Assessment") %>' TextMode="MultiLine" Height="70px" Width="700px"/>
                        <asp:CustomValidator id="custV3" runat="server" ControlToValidate = "TextBox3" ErrorMessage = "Minimum of 25 characters required" ClientValidationFunction="MinLength"/>
                        <asp:RequiredFieldValidator id="RequiredFieldValidator3" ControlToValidate="TextBox3" Text="Assessment Is Required" runat="server"/>
                    </EditItemTemplate>
                     
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Text='<%# Eval("Assessment") %>'/>
                    </ItemTemplate>                       
                </telerik:GridTemplateColumn>
 
                <telerik:GridTemplateColumn HeaderText="Plan" UniqueName="Plann" >
                    <EditItemTemplate>        
                        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Plann") %>' TextMode="MultiLine" Height="70px" Width="700px"/>
                        <asp:CustomValidator id="custV4" runat="server" ControlToValidate = "TextBox4" ErrorMessage = "Minimum of 25 characters required" ClientValidationFunction="MinLength"/>
                        <asp:RequiredFieldValidator id="RequiredFieldValidator4" ControlToValidate="TextBox4" Text="Plan Is Required" runat="server"/>
                    </EditItemTemplate>
 
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text='<%# Eval("Plann") %>'></asp:Label>
                    </ItemTemplate>                     
                </telerik:GridTemplateColumn>
 
                <telerik:GridBoundColumn DataField="UserName" FilterControlAltText="Filter UserName column" HeaderText="UserName" SortExpression="UserName" UniqueName="UserName" Visible="False" ReadOnly="True"/>
                <telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this visit?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                     <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                </telerik:GridButtonColumn>
           </Columns>
 
           <EditFormSettings UserControlName="Home Health Billing">
                <EditColumn FilterControlAltText="Filter EditCommandColumn column"/>
                <PopUpSettings Modal="True" />                         
            </EditFormSettings>
             
            <PagerStyle AlwaysVisible="True"  />          
        </MasterTableView>
 
        <ClientSettings AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true">
            <ClientEvents OnPopUpShowing="PopUpShowing" />
            <Selecting AllowRowSelect="true" />
        </ClientSettings>
 
        <PagerStyle Mode="Advanced" AlwaysVisible="True" />
        <FilterMenu EnableImageSprites="False"/>
    </telerik:RadGrid>

 

I have already attempting using OnItemCommand and checking for InitInsert but during this time the ItemCommandArgs.Item attribute is not a GridDataItem of any kind, it always spits out a cast error when trying to cast it to get at the columns to modify them as per our requirements.

 

The crux of it is that some way, either once the initinsert command has been issues or when the popup modal open command is issues we need to get into the popup window and make changes and then we also need to make changes when the status is changed.

 

How would we access the open popup modal from an OnSelectedIndexChanged sub?  My first guess would be getting the tableview through the owner of the sender parameter but that will only be applicable if the controls in the popup can remain grid elements.

 

Is something that can be done with a RadGrid or will we need to re-engineer the page to implement this?

 

Thanks.

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 16 Jan 2019, 06:31 PM
Hi Geo,

I would highly recommend one of most common articles every developer needs is the Accessing Cells and Rows. This describes the most common ways of accessing controls and will give you a better understanding on how it's done.

I will also show you an example that would give you an idea of how to achieve the required behavior.

Let's assume the there is GridDropDownColumn with a DropDownType set to RadCombobox and this combos is wired up with its OnSelectedIndexChanged event. In the event handler you would something like the example below:

' SelectedIndexChanged event of the first combo
Protected Sub RadComboBox1_SelectedIndexChanged(sender As Object, e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs)
    '' status combo
    Dim combo1 As RadComboBox = DirectCast(sender, RadComboBox)
 
    'get reference to the edit form item by using the NamingContainer property. Similar to Control.Parent
    Dim editFormItem = TryCast(combo1.NamingContainer, GridEditFormItem)
    'find the combo in another GridDropDownColumn
    Dim combo2 As RadComboBox = TryCast(editFormItem("SomeDropDownColumn").Controls(0), RadComboBox)
    'change the second combo's selectio, visibility, etc.. based on the first first combo's selected item
    combo2.SelectedIndex = combo1.SelectedIndex
End Sub

Please let us know if you have any questions.

Kind regards,
Attila Antal
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Geo
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question
or