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

White columns w/o controls in edit mode

1 Answer 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
blablabla
Top achievements
Rank 1
blablabla asked on 09 Dec 2011, 11:13 AM
I'm having a weird problem with some of the RadGrids I'm using. Certain columns appear all in white and without any controls in them when in edit mode. This happens in IE, Chrome, and Firefox (except the column is yellow in Firefox), and I don't understand why.

You can see 2 pics of the grid attached below. One is in read only mode, and the other is in edit mode. Do notice that I am using inplace editing and making all of the rows editable.

Here's the aspx code (I renamed some column and control names).

<telerik:RadGrid ID="radgrid1" AutoGenerateColumns="False" runat="server"
    GridLines="None" Skin="Office2007" CellSpacing="0" DataSourceID="radgrid1DataSource"
    OnItemInserted="radgrid1_ItemInserted" AllowAutomaticInserts="true"
    OnItemDataBound="radgrid1_ItemDataBound" OnItemCommand="radgrid1_ItemCommand"
    AllowAutomaticDeletes="true" ValidationSettings-EnableValidation="false">
    <MasterTableView DataKeyNames="KeyID" EditMode="InPlace" AllowAutomaticInserts="true"
        AllowAutomaticDeletes="true">
        <Columns>
            <telerik:GridBoundColumn DataField="KeyID" Visible="false" UniqueName="KeyID"
                HeaderText="<%$ Resources:GlobalResources, KeyID %>" />
            <telerik:GridBoundColumn DataField="ProjectID" Visible="false" UniqueName="ProjectID"
                HeaderText="<%$ Resources:GlobalResources, ProjectID %>" />
            <telerik:GridBoundColumn DataField="Name" UniqueName="Name"
                HeaderText="<%$ Resources:GlobalResources, Name%>" />
            <telerik:GridNumericColumn DataField="InitialAmount" NumericType="Number"
                DataFormatString="{0:N}" DecimalDigits="2" UniqueName="InitialAmount"
                HeaderText="<%$ Resources:GlobalResources, InitialAmount%>" />
            <telerik:GridTemplateColumn UniqueName="CurrencyCode" ItemStyle-Width="260px"
                HeaderText="<%$ Resources:GlobalResources, CurrencyCode %>">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "CurrencyCode") %>
                </ItemTemplate>
                <EditItemTemplate>
                    <cc:CurrencyDropDownList ID="ddlCurrency" runat="server" IsAlertsVisible="false"
                        IsLockVisible="false" IsHistoryVisible="false" IsFieldLabelVisible="false" IsReadOnly="false"
                        IncludeNullValue="false" MyDropDownList-SelectedValue='<%# Bind("CurrencyCode") %>' />
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
             
            <telerik:GridCheckBoxColumn DataField="ToDelete" UniqueName="ToDelete" HeaderText="Delete" />
            <telerik:GridEditCommandColumn ButtonType="PushButton" InsertText="Confirm" EditText="Edit"
                CancelText="Cancel" UniqueName="EditCommandColumn" />
        </Columns>
        <NoRecordsTemplate>
            No Records Found.
        </NoRecordsTemplate>
        <CommandItemTemplate>
            <table cellpadding="5" style="width: 100%">
                <tr>
                    <td align="left">
                        <asp:LinkButton ID="btnAddNewRecord" runat="server" CommandName="InitInsert">
                            <img style="border:0px" alt="" src="../Images/add.png" />Add New Record
                        </asp:LinkButton>
                    </td>
                    <td align="right">
                        <asp:LinkButton ID="btnDeleteSelected" runat="server" CommandName="DeleteSelected"
                            OnClientClick="javascript:return confirm('Delete all selected records?')">
                            <img src="../Images/delete.png" alt="" style="border:0px" />Delete Selected
                        </asp:LinkButton>
                    </td>
                </tr>
            </table>
        </CommandItemTemplate>
    </MasterTableView>
</telerik:RadGrid>


Here's some of the only relevant C# code (i.e. relevant to the ToDelete column and the grid itself):

protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsInEditMode)
            {
                for (int i = 0; i < this.radgrid1.PageSize; i++)
                {
                    this.radgrid1.EditIndexes.Add(i);
                }
 
                this.radgrid1.Columns.FindByUniqueName("ToDelete").Visible = true;
                this.radgrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Bottom;
            }
            else
            {
                this.radgrid1.Columns.FindByUniqueName("ToDelete").Visible = false;
                this.radgrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None;
            }
        }
 
protected void radgrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e != null)
            {
                if (e.Item is GridDataItem && !e.Item.IsInEditMode)
                {
                    GridDataItem item = e.Item as GridDataItem;
                    Button editButton = (Button)item.Controls[item.Controls.Count - 1].Controls[0];
                    editButton.Visible = false;
                }
                else if (e.Item is GridDataInsertItem && e.Item.IsInEditMode)
                {
                    GridDataInsertItem item = e.Item as GridDataInsertItem;
                    Button insertButton = (Button)item.Controls[item.Controls.Count - 1].Controls[0];
                    Button cancelButton = (Button)item.Controls[item.Controls.Count - 1].Controls[2];
                    insertButton.Visible = true;
                    cancelButton.Visible = true;
                }
                else if (e.Item is GridDataItem && e.Item.IsInEditMode)
                {
                    GridEditableItem item = e.Item as GridEditableItem;
                    Button editButton = (Button)item.Controls[item.Controls.Count - 1].Controls[0];
                    Button cancelButton = (Button)item.Controls[item.Controls.Count - 1].Controls[2];
                    editButton.Visible = false;
                    cancelButton.Visible = false;
                }
            }
        }


Basically, when I'm in readonly mode, I hide the ToDelete column, the Edit/Update/Cancel buttons and I do not display the commanditem controls.

In Edit mode, I display the ToDelete column and hide the Edit/Update/Cancel buttons. On the other hand, I display the command item controls.

Any help?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 14 Dec 2011, 05:10 PM
Hi Blablabla,

I tried to replicate the described problem, but to no avail. Can you please send us the definition for IsInEditMode method?

Kind regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
blablabla
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or