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

making html table row invisible in editform mode

2 Answers 153 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Henk
Top achievements
Rank 1
Henk asked on 21 Sep 2014, 12:33 PM
Hi,

I have a radgrid and in editform mode I have define a table with rows and columns. For some grouping condition in the radgrid I want to make a row invisible. I try in the itemcommand or itemdatabound using  Table mytable=<>.findcontrol("tableID")  as Table; and for example myTable..Rows[0].Visible = false;  and but I see myTable is alway null....

Grid defintion
<telerik:RadFormDecorator Runat="server"></telerik:RadFormDecorator>
<telerik:RadAjaxLoadingPanel Runat="server" Skin="Default"></telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxManager runat="server">
    <ajaxsettings>
        <telerik:AjaxSetting AjaxControlID="DocWerkVAftekenGrid">
            <updatedcontrols>
                <telerik:AjaxUpdatedControl ControlID="DocWerkVAftekenGrid" UpdatePanelCssClass="" LoadingPanelID="RadAjaxLoadingPanel1"/>
            </updatedcontrols>
        </telerik:AjaxSetting>
    </ajaxsettings>
</telerik:RadAjaxManager>
<asp:Label ID="WerkVoorraad" runat="server" BackColor="#3399FF" Height="30px" Text="Aftekenen Verrichtingen" Width="100%"></asp:Label>
<telerik:RadGrid ID="DocWerkVAftekenGrid" runat="server" AutoGenerateColumns="False" OnItemDataBound="DocWerkVAftekenGrid_ItemDataBound" OnUpdateCommand="DocWerkVAftekenGrid_UpdateCommand" OnNeedDataSource="DocWerkVAftekenGrid_NeedDataSource" OnItemCommand="DocWerkVAftekenGrid_ItemCommand" >
    <exportsettings>
        <pdf pagewidth="">
        </pdf>
    </exportsettings>
    <ClientSettings Selecting-AllowRowSelect="true" AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true">
        <Selecting AllowRowSelect="True"></Selecting>
        <scrolling allowscroll="True" usestaticheaders="True" />
    </ClientSettings>
   <mastertableview DataKeyNames="docent_id, patient_id, blok_id, str_vcrowid">
                                 <GroupByExpressions>
                                    <telerik:GridGroupByExpression>
                                        <GroupByFields>
                                            <telerik:GridGroupByField FieldName="verrichting"></telerik:GridGroupByField>
                                        </GroupByFields>
                                        <SelectFields>
                                            <telerik:GridGroupByField FieldName="verrichting" HeaderText="AftekenSoort"></telerik:GridGroupByField>
                                        </SelectFields>
                                    </telerik:GridGroupByExpression>
                                </GroupByExpressions>
       <Columns>
            <telerik:GridEditCommandColumn UniqueName="EditContactColumn"/>                
            <telerik:GridHyperLinkColumn AllowSorting="False" DataNavigateUrlFields="patient_id" DataNavigateUrlFormatString="http://localhost/EPDBehandelApp/Behandeling.aspx?PatientID={0}" DataTextField="patient_id" DataTextFormatString="Behandelkaart" FilterControlAltText="Filter behandelkaart column" Text="Behandelkaart" UniqueName="behandelkaart" Target="_blank">
                <ItemStyle Font-Bold="True" />
            </telerik:GridHyperLinkColumn>
            <telerik:GridBoundColumn DataField="blokcode" FilterControlAltText="Filter blokcode column" HeaderText="Blok code" UniqueName="blokcode">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="patient" FilterControlAltText="Filter patient column" HeaderText="Patient" UniqueName="patient">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="behandelaar" FilterControlAltText="Filter student column" HeaderText="Student" UniqueName="student">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="doorlooptijd" FilterControlAltText="Filter doorlooptijd column" HeaderText="Duur/dag" UniqueName="doorlooptijd">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="verrichting_naam" FilterControlAltText="Filter verrichting_naam column" HeaderText="Verrichting" UniqueName="verrichting_naam">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="verrichting_code" FilterControlAltText="Filter verrichting_code column" HeaderText="Code" UniqueName="verrichting_code">
            </telerik:GridBoundColumn>
            <telerik:GridButtonColumn DataTextField="elementcode" FilterControlAltText="Filter elementcode column" HeaderText="Element" UniqueName="elementcode">
            </telerik:GridButtonColumn>
            <telerik:GridBoundColumn DataField="vlakcodes" FilterControlAltText="Filter vlakcodes column" HeaderText="Vlak" UniqueName="vlakcodes">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="docent_id" Display="False" FilterControlAltText="Filter docent_id column" HeaderText="DocentID" UniqueName="docent_id">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="patient_id" Display="False" FilterControlAltText="Filter patient_id column" HeaderText="PatientID" UniqueName="patient_id">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="blok_id" Display="False" FilterControlAltText="Filter blok_id column" HeaderText="BlokID" UniqueName="blok_id">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="str_vcrowid" Display="False" FilterControlAltText="Filter blok_id column" HeaderText="VRowID" UniqueName="str_vcrowid">
            </telerik:GridBoundColumn>
        </Columns>
            <EditFormSettings EditFormType="Template">
                <FormTemplate>
                    <table ID="AftekenTable"  cellspacing="20" border="0" rules="none" >
                        <tr ID="eenheid">
                            <td>Eenheid</td>
                            <td><telerik:RadComboBox ID="EenheidComboBox"  DataTextField="CODE_OMS" DataValueField="CODE_OMS" runat="server" /></td>
                        </tr>
                        <tr  ID="score">
                            <td>Score</td>
                            <td>
                                    <asp:TextBox ID="ScoreTextBox" runat="server" Text='<%# Bind("score") %>' runat="server"/>
                            </td>
                        </tr>
                        <tr>
                            <td>Vervanger</td>
                            <td>
                                <asp:CheckBox ID="TmpDocDefCheckBox" runat="server" Enabled="True" />
                            </td>
                        </tr>
                        <tr>
                            <td>Administratief</td>
                            <td>
                                <asp:CheckBox ID="AdminCheckBox" runat="server" Enabled="True" />
                            </td>
                        </tr>
                        <tr>
                            <td>Opmerking</td>
                            <td>
                                <asp:TextBox ID="OpmTextBox" runat="server" runat="server"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'/>
                            <td> <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"/></td>      
                        </tr>
                    </table>
                </FormTemplate>
            </EditFormSettings>

    </mastertableview>
</telerik:RadGrid>

        protected void DocWerkVAftekenGrid_ItemDataBound(object sender, GridItemEventArgs e)
        {

            if (e.Item is GridEditFormItem && e.Item.IsInEditMode && !(e.Item is GridEditFormInsertItem))
            {
                GridEditFormItem editForm = e.Item as GridEditFormItem;
                RadComboBox tlist = editForm.FindControl("EenheidComboBox") as RadComboBox;
                tlist.Items.Clear();
                tlist.DataSource = EPDDatasets.GetCodeList("CMS_CODES", "Eenheden");
                tlist.DataBind();
                Table AftekenTabl = editForm.FindControl("AftekenTable") as Table;
                if (AftekenTabl != null) <--- But it is always null !!!
                AftekenTabl.Rows[0].Visible = false;
            }

        }

        protected void DocWerkVAftekenGrid_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {
             GridEditableItem editedItem = e.Item as GridEditableItem;
             Table AftekenTabl = editedItem.FindControl("AftekenTable") as Table;
             if (AftekenTabl != null)  <-- also null thus not working....
                 AftekenTabl.Rows[0].Visible = false;

            }

        }

How can I achieve that the row "eenheid"and "score"is invisible when group column is equal to some condtion?

Thanks in advance,

Henk

2 Answers, 1 is accepted

Sort by
0
Accepted
Viktor Tachev
Telerik team
answered on 24 Sep 2014, 01:59 PM
Hello Henk,

The table cannot be accessed on the server as it is not a server control. If you would like to get reference to the table rows server-side you could add runat="server" to the tr elements. After this you would be able to get reference to the table rows on the server and set their Visible property. Check the following snippets for illustration:

Markup for the Score row:

<tr id="score" runat="server">
    <td>Score</td>
    <td>
        <asp:TextBox ID="ScoreTextBox" runat="server" Text='asda' runat="server" />
    </td>
</tr>

ItemDataBound handler:

Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
        Dim editItem As GridEditableItem = TryCast(e.Item, GridEditableItem)
 
        editItem.FindControl("score").Visible = False
    End If
End Sub



Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Henk
Top achievements
Rank 1
answered on 24 Sep 2014, 03:17 PM
Thanks!
Tags
Grid
Asked by
Henk
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Henk
Top achievements
Rank 1
Share this question
or