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

Accessing RadGrid EditItem To Add Control

1 Answer 17 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 14 Oct 2014, 07:51 PM
Hi,

We have to grids on a page that when on the update/insert command event, if the validation code finds an error, it adds an exclamation mark image to GridEditCommandColumn along with a corresponding tooltip to let the user know what the error was and where. It works perfectly in the top grid, which is essentially a parent grid for the one below it. The code below is showing how the validation/error works for both grids:

 protected void FundGrid_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            Telerik.Web.UI.GridEditableItem editedItem = e.Item as Telerik.Web.UI.GridEditableItem;

            Hashtable newValues = new Hashtable();
            editedItem.ExtractValues(newValues);

            Decimal grndkey = (Decimal)GroundGrid.MasterTableView.DataKeyValues[GroundGrid.SelectedItems[0].ItemIndex][GroundCardColumn.GroundId.ToString()];
            newValues[GroundFundingColumn.GroundId.ToString()] = grndkey;

            List<String> errorlist = new List<string>();
            GroundFunding gf = null;
            e.Canceled = !((IGroundCardTask)ServiceManager).UpdateFunding(this.UserContext, ref gf, newValues, errorlist);
            if (e.Canceled)
                showGridRowUpdateError(editedItem, errorlist);
            else
            {
                if (errorlist.Count > 0)
                {
                    handleFundingStatusChangedNotification(gf.GroundId, errorlist);
                }
            }
        }

And the following code is how the edit item and error list are displayed to the customer:

 private void showGridRowUpdateError(Telerik.Web.UI.GridEditableItem editItem, List<String> errors)
        {
            //
            TableCell cmdCell = ((Telerik.Web.UI.GridDataItem)editItem)["Cmd"];

            Image img = new Image();
            img.ID = "ErrorImage";
            img.ImageUrl = "~/Images/ErrorAlertSmall.gif";
            img.CssClass = "ErrorAlertPopup";

            cmdCell.Controls.Add(img);

            BulletedList bulletList = new BulletedList();
            bulletList.ID = "ErrorList";
            bulletList.CssClass = "ErrorBulletList";

            foreach (String sMessage in errors)
            {
                bulletList.Items.Add(new ListItem(sMessage));
            }

            ErrorToolTip.TargetControlID = img.ClientID;
            ErrorToolTip.IsClientID = true;
            ErrorToolTip.Controls.Add(bulletList);
            ErrorToolTip.Show();
        }

For some reason, this does not work on on the bottom Funding Grid. Works perfectly everywhere else in the solution, but not here. The grid is marked up as follows:

<telerik:RadGrid ID="FundGrid" runat="server"
                                AutoGenerateColumns="False"
                                GridLines="None"
                                Width="740px"
                                onneeddatasource="FundGrid_NeedDataSource"
                                onitemdatabound="FundGrid_ItemDataBound"
                                OnItemCreated="FundGrid_ItemCreated"
                                ondeletecommand="FundGrid_DeleteCommand"
                                oninsertcommand="FundGrid_InsertCommand"
                                onupdatecommand="FundGrid_UpdateCommand"
                                OnDataBound="FundGrid_DataBound"
                                AllowMultiRowEdit="false"
                                Enabled="false"
                                EnableLinqExpressions="false">
                      <MasterTableView Caption="Funding Data for Ground Card: " EditMode="InPlace" ShowFooter="True" DataKeyNames="GroundId,FundingOrdBy" Width="740px">
                                    <RowIndicatorColumn>
                                        <HeaderStyle Width="20px" />
                                    </RowIndicatorColumn>
                                    <ExpandCollapseColumn>
                                        <HeaderStyle Width="20px" />
                                    </ExpandCollapseColumn>
                                    <Columns>
                                        <telerik:GridEditCommandColumn UniqueName="cmd" CancelText="Go Bac" EditText="Edit" InsertText="Insert"
                                            UpdateText="Update" ButtonType="ImageButton">
                                            <HeaderStyle Width="50px" />
                                        </telerik:GridEditCommandColumn>
                                        <telerik:GridBoundColumn HeaderText="Ground Id" DataField="GroundId" UniqueName="GroundId" ReadOnly="true" Visible="false">
                                            <HeaderStyle Width="100px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="Receiver Cost Ctr" DataField="ReceiverCostCtr" UniqueName="ReceiverCostCtr" MaxLength="10">
                                            <HeaderStyle Width="110px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="Receiver Network" DataField="ReceiverNetwork" UniqueName="ReceiverNetwork" MaxLength="24">
                                            <HeaderStyle Width="150px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="Receiver Activity" DataField="ReceiverOperation" UniqueName="ReceiverOperation" MaxLength="8">
                                            <HeaderStyle Width="110px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridNumericColumn HeaderText="Hours" DataType="System.Decimal" Aggregate="Sum" FooterText=" " DataField="Hrs" DataFormatString="{0:F1}" UniqueName="Hrs" MaxLength="5">
                                            <HeaderStyle Width="40px" />
                                        </telerik:GridNumericColumn>
                                    </Columns>
                                </MasterTableView>
                                <ClientSettings>
                                    <Selecting AllowRowSelect="True" />
                                    <Scrolling AllowScroll="True" ScrollHeight="90px" UseStaticHeaders="True" />
                                    <ClientEvents OnRowContextMenu="FundingRowContextMenu" OnRowDblClick="RowDblClick" />
                                </ClientSettings>
                            </telerik:RadGrid>

Any help at all would be appreciated. Been struggling with this for several days and have not been able to add/clear any of the controls on the grid column.

Thanks,

- Joe

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 17 Oct 2014, 12:26 PM
Hi Joe,

Try removing the Enabled="false" property from the grid definition and see if the issue still remains. In addition, I can suggest that you temporarily remove any ajaxification on the page if present and enable your script debugger (FireBug or F12) to check whether there are any script errors interfering.

If the problem persists, please open a formal support ticket and send us a very basic runnable web site demonstrating the issue.

Regards,
Eyup
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.

 
Tags
General Discussions
Asked by
Joe
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or