Custom Edit Column With User Control

2 posts, 0 answers
  1. Tim
    Tim avatar
    60 posts
    Member since:
    May 2011

    Posted 01 Nov 2011 Link to this post

    The problem that I am having is that the custom user control is not displaying for a DetailTableView.EditFormSettings when using a GridButtonColumn as the firing event.

    I have a class that defines a Hierarchical RadGrid that I will be using application wide. This grid has many column so this is the best implementation for me.
    using System;
    using System.Data;
    using System.Drawing;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
     
    namespace MAAS.WebApplication.Controls
    {
        public static class BatchRadGrid
        {
     
            internal static RadGrid GridDefinition(string id)
            {
                RadGrid _policyRadGrid = new RadGrid
                                             {
                                                 ID = id,
                                                 Width = Unit.Percentage(98),
                                                 Height = Unit.Pixel(460),
                                                 PageSize = 10,
                                                 AllowPaging = true,
                                                 EnableAjaxSkinRendering = true,
                                                 AllowSorting = true,
                                                 AutoGenerateColumns = false,
                                                 ShowStatusBar = true,
                                                 GridLines = GridLines.None,
                                                 AutoGenerateEditColumn = false,
                                                 AutoGenerateDeleteColumn = false,
                                                 ExportSettings =
                                                     {
                                                         HideStructureColumns = true,
                                                         ExportOnlyData = true,
                                                         IgnorePaging = true,
                                                     },
                                                 HeaderContextMenu =
                                                     {
                                                         Enabled = true,
                                                         CssClass = "GridContextMenu GridContextMenu_Web20"
                                                     },
                                                 PagerStyle = {Mode = GridPagerMode.NextPrevNumericAndAdvanced},
                                                 ClientSettings =
                                                     {
                                                         Scrolling = {AllowScroll = true, UseStaticHeaders = true},
                                                         Selecting = {AllowRowSelect = true},
                                                         AllowExpandCollapse = true,
                                                         ClientEvents = {OnRowDblClick = "RowDblClicked"}
     
                                                     },
                                                 FilterMenu = {EnableImageSprites = false},
                                                 MasterTableView =
                                                     {
                                                         PageSize = 10,
                                                         CommandItemDisplay = GridCommandItemDisplay.Top,
                                                         CommandItemSettings =
                                                             {
                                                                 ShowExportToExcelButton = false,
                                                                 AddNewRecordText = "Add New Batch"
                                                             },
                                                         EnableHeaderContextMenu = true,
                                                         HorizontalAlign = HorizontalAlign.NotSet,
                                                         EditFormSettings =
                                                             {
                                                                 FormCaptionStyle = {CssClass = "EditFormHeader"},
                                                                 ColumnNumber = 3,
                                                                 CaptionDataField = "BatchID",
                                                                 CaptionFormatString = "Edit properties of Item {0}",
                                                                 InsertCaption = "New Batch",
                                                                 FormTableItemStyle = {Wrap = false},
                                                                 FormMainTableStyle =
                                                                     {
                                                                         BackColor = Color.FromArgb(222, 222, 214),
                                                                         CellPadding = 3,
                                                                         CellSpacing = 0,
                                                                         GridLines = GridLines.None,
                                                                         Width = Unit.Percentage(43)
                                                                     },
                                                                 FormTableStyle =
                                                                     {
                                                                         BackColor = Color.FromArgb(222, 222, 214),
                                                                         CellPadding = 2,
                                                                         CellSpacing = 0,
                                                                         Height = Unit.Percentage(100)
                                                                     },
                                                                 FormTableAlternatingItemStyle = {Wrap = false},
                                                                 FormTableButtonRowStyle =
                                                                     {
                                                                         HorizontalAlign = HorizontalAlign.Right,
                                                                         CssClass = "EditFormButtonRow"
                                                                     },
                                                             },
                                                         HierarchyLoadMode = GridChildLoadMode.ServerBind,
                                                         DataKeyNames = new string[] {"BatchID"},
                                                         EditMode = GridEditMode.PopUp,
                                                     },
                                             };
     
                //Add Edit Column
                GridEditCommandColumn _masterGridEditCommandColumn = new GridEditCommandColumn
                                                                         {
                                                                             ButtonType = GridButtonColumnType.ImageButton,
                                                                             HeaderText = "",
                                                                             UniqueName = "MasterEditRecord",
                                                                             HeaderStyle = {Width = Unit.Pixel(20)},
                                                                             ItemStyle = {Width = Unit.Pixel(20)}
                                                                         };
                _policyRadGrid.MasterTableView.Columns.Add(_masterGridEditCommandColumn);
     
                //Add Delete Column
                GridButtonColumn _masterDeleteCommandColumn = new GridButtonColumn
                                                                  {
                                                                      ConfirmText = "Confirm",
                                                                      ConfirmDialogType = GridConfirmDialogType.RadWindow,
                                                                      ButtonType = GridButtonColumnType.ImageButton,
                                                                      HeaderText = "",
                                                                      ConfirmTitle = "Delete",
                                                                      CommandName = "Delete",
                                                                      Text = "Delete",
                                                                      UniqueName = "MasterDeleteRecord",
                                                                      HeaderStyle = {Width = Unit.Pixel(20)},
                                                                      ItemStyle =
                                                                          {
                                                                              HorizontalAlign = HorizontalAlign.Center,
                                                                              Width = Unit.Pixel(20)
                                                                          }
                                                                  };
     
                _policyRadGrid.MasterTableView.Columns.Add(_masterDeleteCommandColumn);
     
     
                GridButtonColumn _masterPromoteCommandColumn = new GridButtonColumn
                                                                   {
                                                                       ConfirmText = "Confirm",
                                                                       ConfirmDialogType = GridConfirmDialogType.RadWindow,
                                                                       ButtonType = GridButtonColumnType.ImageButton,
                                                                       HeaderText = "",
                                                                       ConfirmTitle = "Promote Batch",
                                                                       CommandName = "Promote",
                                                                       Text = "Promote",
                                                                       UniqueName = "MasterPromoteRecord",
                                                                       HeaderStyle = {Width = Unit.Pixel(20)},
                                                                       ItemStyle =
                                                                           {
                                                                               HorizontalAlign = HorizontalAlign.Center,
                                                                               Width = Unit.Pixel(20)
                                                                           }
                                                                   };
                _policyRadGrid.MasterTableView.Columns.Add(_masterPromoteCommandColumn);
     
                GridBoundColumn _masterBoundColumn = new GridBoundColumn
                                                         {
                                                             DataField = "BatchID",
                                                             HeaderText = "Batch ID",
                                                             UniqueName = "BatchID",
                                                             HeaderStyle = {Width = Unit.Pixel(50)},
                                                             ItemStyle = {Width = Unit.Pixel(50)},
                                                             ReadOnly = true,
                                                         };
                _policyRadGrid.MasterTableView.Columns.Add(_masterBoundColumn);
     
                _masterBoundColumn = new GridBoundColumn
                                         {
                                             DataField = "AccountingPeriodID",
                                             HeaderText = "Accounting Period",
                                             UniqueName = "AccountingPeriodID",
                                             HeaderStyle = {Width = Unit.Pixel(130)},
                                             ItemStyle = {Width = Unit.Pixel(130)},
                                             ReadOnly = true,
                                         };
                _policyRadGrid.MasterTableView.Columns.Add(_masterBoundColumn);
                _masterBoundColumn = new GridBoundColumn
                                         {
                                             DataField = "BatchName",
                                             HeaderText = "Batch Name",
                                             UniqueName = "BatchName",
                                             HeaderStyle = {Width = Unit.Pixel(200)},
                                             ItemStyle = {Width = Unit.Pixel(200)},
                                             ReadOnly = true,
                                         };
                _policyRadGrid.MasterTableView.Columns.Add(_masterBoundColumn);
     
                _masterBoundColumn = new GridBoundColumn
                                         {
                                             DataField = "BatchStatusName",
                                             HeaderText = "Batch Status",
                                             UniqueName = "BatchStatusName",
                                             HeaderStyle = {Width = Unit.Pixel(80)},
                                             ItemStyle = {Width = Unit.Pixel(80)},
                                             ReadOnly = true,
                                         };
                _policyRadGrid.MasterTableView.Columns.Add(_masterBoundColumn);
     
                _masterBoundColumn = new GridBoundColumn
                                         {
                                             DataField = "BatchDescription",
                                             HeaderText = "Batch Description",
                                             UniqueName = "BatchDescription",
                                             HeaderStyle = {Width = Unit.Percentage(100)},
                                             ItemStyle = {Width = Unit.Percentage(100)},
                                         };
                _policyRadGrid.MasterTableView.Columns.Add(_masterBoundColumn);
     
     
                // (II in hierarchy level) Detail table - Manual Adjustments of the Batch
     
                GridTableView _batchAdjustments = new GridTableView(_policyRadGrid)
                                                      {
                                                          ID = string.Format("{0}_ChildGrid", id),
                                                          Name = string.Format("{0}_ChildGrid", id),
                                                          DataMember = "Policy",
                                                          AutoGenerateColumns = false,
                                                          Width = Unit.Percentage(100),
                                                          PageSize = 10,
                                                          BackColor = Color.FromArgb(198, 203, 214),
                                                          CommandItemDisplay = GridCommandItemDisplay.Top,
                                                          CommandItemSettings =
                                                              {
                                                                  ShowExportToExcelButton = true,
                                                                  AddNewRecordText = "Add New Adjustment",
     
                                                              },
                                                          EnableHeaderContextMenu = true,
                                                          HorizontalAlign = HorizontalAlign.NotSet,
                                                          EditFormSettings =
                                                              {
                                                                  EditColumn =
                                                                      {
                                                                          UniqueName = "EditRecord",
                                                                      },
                                                              },
                                                          HierarchyLoadMode = GridChildLoadMode.ServerOnDemand,
                                                          EditMode = GridEditMode.PopUp,
                                                      };
     
                GridRelationFields _relationFields = new GridRelationFields
                                                         {
                                                             MasterKeyField = "BatchID",
                                                             DetailKeyField = "ManualAdjustmentBatchId"
                                                         };
                _batchAdjustments.ParentTableRelation.Add(_relationFields);
     
                _policyRadGrid.MasterTableView.DetailTables.Add(_batchAdjustments);
     
     
                //Add Edit Column
                GridEditCommandColumn _gridEditCommandColumn = new GridEditCommandColumn
                                                                   {
                                                                       ButtonType = GridButtonColumnType.ImageButton,
                                                                       HeaderText = "",
                                                                       UniqueName = "PolicyEditRecord",
                                                                       HeaderStyle = {Width = Unit.Pixel(33)},
                                                                       ItemStyle =
                                                                       {
                                                                           HorizontalAlign = HorizontalAlign.Center,
                                                                           Width = Unit.Pixel(33)
                                                                       },
                                                                   };
                _batchAdjustments.Columns.Add(_gridEditCommandColumn);
     
                //Add Delete Column GridButtonColumn
                GridButtonColumn _deleteCommandColumn = new GridButtonColumn
                                                            {
                                                                ButtonType = GridButtonColumnType.ImageButton,
                                                                CommandName = "Delete",
                                                                UniqueName = "DeleteTransaction",
                                                                HeaderStyle = {Width = Unit.Pixel(33)},
                                                                ItemStyle =
                                                                    {
                                                                        HorizontalAlign = HorizontalAlign.Center,
                                                                        Width = Unit.Pixel(33)
                                                                    },
                                                            };
     
     
                _batchAdjustments.Columns.Add(_deleteCommandColumn);
     
                //Add columns           
                GridBoundColumn _boundColumn = new GridBoundColumn
                                                   {
                                                       DataField = "ManualAdjustmentBatchId",
                                                       HeaderText = "ManualAdjustmentBatchId",
                                                       UniqueName = "ManualAdjustmentBatchId",
                                                       HeaderStyle = {Width = Unit.Pixel(100)},
                                                       ItemStyle = {Width = Unit.Pixel(100)},
                                                       Visible = false,
                                                       ReadOnly = true,
                                                   };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                                   {
                                                       DataField = "ManualAdjustmentId",
                                                       HeaderText = "Manual Adjustment Id",
                                                       UniqueName = "ManualAdjustmentId",
                                                       HeaderStyle = {Width = Unit.Pixel(100)},
                                                       ItemStyle = {Width = Unit.Pixel(100)},
                                                       Visible = false,
                                                       ReadOnly = true,
                                                   };
                _batchAdjustments.Columns.Add(_boundColumn);
     
     
                _boundColumn = new GridBoundColumn
                                                   {
                                                       DataField = "OriginatingSystemCode",
                                                       HeaderText = "Originating System Code",
                                                       UniqueName = "OriginatingSystemCode",
                                                       HeaderStyle = {Width = Unit.Pixel(100)},
                                                       ItemStyle = {Width = Unit.Pixel(100)},
                                                       Visible = false,
                                                       ReadOnly = true,
                                                   };
                _batchAdjustments.Columns.Add(_boundColumn);
     
     
                _boundColumn = new GridBoundColumn
                                   {
                                       DataField = "PolicyNumber",
                                       HeaderText = "Policy Number",
                                       UniqueName = "PolicyNumber",
                                       HeaderStyle = {Width = Unit.Pixel(100)},
                                       ItemStyle = {Width = Unit.Pixel(100)},
                                       EditFormColumnIndex = 0,
                                   };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                   {
                                       DataField = "PolicyVersion",
                                       HeaderText = "Policy Version",
                                       UniqueName = "PolicyVersion",
                                       HeaderStyle = {Width = Unit.Pixel(100)},
                                       ItemStyle = {Width = Unit.Pixel(100)},
                                       EditFormColumnIndex = 1,
                                   };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                   {
                                       DataField = "InternalLegalEntityCode",
                                       HeaderText = "Internal Legal Entity Code",
                                       UniqueName = "InternalLegalEntityCode",
                                       HeaderStyle = {Width = Unit.Pixel(100)},
                                       ItemStyle = {Width = Unit.Pixel(100)},
                                       EditFormColumnIndex = 2,
                                   };
                _batchAdjustments.Columns.Add(_boundColumn);
     
     
                _boundColumn = new GridBoundColumn
                                   {
                                       DataField = "ProductLine2Name",
                                       HeaderText = "Product Line 2 Name",
                                       UniqueName = "ProductLine2Name",
                                       HeaderStyle = {Width = Unit.Pixel(100)},
                                       ItemStyle = {Width = Unit.Pixel(100)},
                                       EditFormColumnIndex = 3
                                   };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                   {
                                       DataField = "DirectAssumedCededCode",
                                       HeaderText = "Direct Assumed Ceded Code",
                                       UniqueName = "DirectAssumedCededCode",
                                       HeaderStyle = {Width = Unit.Pixel(100)},
                                       ItemStyle = {Width = Unit.Pixel(100)},
                                       EditFormColumnIndex = 0,
     
                                   };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                   {
                                       DataField = "PolicyTransactionTypeCode",
                                       HeaderText = "Policy Transaction Type Code",
                                       UniqueName = "PolicyTransactionTypeCode",
                                       HeaderStyle = {Width = Unit.Pixel(100)},
                                       ItemStyle = {Width = Unit.Pixel(100)},
                                       EditFormColumnIndex = 1
                                   };
     
            _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                     {
                                         DataField = "FinancialAmount",
                                         HeaderText = "Financial Amount",
                                         UniqueName = "FinancialAmount",
                                         HeaderStyle = {Width = Unit.Pixel(100)},
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 2,
                                         DataFormatString = "{0:C}"
                                     };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                GridDateTimeColumn _bounddtColumn = new GridDateTimeColumn
                {
                                       DataField = "PolicyEffectiveDate",
                                       HeaderText = "Policy Effective Date",
                                       UniqueName = "PolicyEffectiveDate",
                                       HeaderStyle = {Width = Unit.Pixel(100)},
                                       ItemStyle = {Width = Unit.Pixel(100)},
                                       EditFormColumnIndex = 3,
                                       DataFormatString = "{0:M/d/yyyy}",
                                   };
                _batchAdjustments.Columns.Add(_bounddtColumn);
     
                _boundColumn = new GridBoundColumn
                                          {
                                              DataField = "CoverageMarkelCode",
                                              HeaderText = "Coverage Markel Code",
                                              UniqueName = "CoverageMarkelCode",
                                              HeaderStyle = { Width = Unit.Pixel(100) },
                                              ItemStyle = {Width = Unit.Pixel(100)},
                                              Visible = false,
                                              ReadOnly = true,
                                          };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                     {
                                         DataField = "AnnualStatementLineNAICCode",
                                         HeaderText = "Annual Statement Line NAIC Code",
                                         UniqueName = "AnnualStatementLineNAICCode",
                                         HeaderStyle = { Width = Unit.Pixel(100) },
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 0,
                                     };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                     {
                                         DataField = "InwardAssumingCompanyCode",
                                         HeaderText = "Inward Assuming Company Code",
                                         UniqueName = "InwardAssumingCompanyCode",
                                         HeaderStyle = { Width = Unit.Pixel(100) },
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 1,
                                     };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                   {
                                       DataField = "ProducerCode",
                                       HeaderText = "Producer Code",
                                       UniqueName = "ProducerCode",
                                       HeaderStyle = {Width = Unit.Pixel(100)},
                                       ItemStyle = {Width = Unit.Pixel(100)},
                                       EditFormColumnIndex = 2,
                                       DataFormatString = "{0:MM/dd/yyyy}",
                                   };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                     {
                                         DataField = "LegacyProgramCode",
                                         HeaderText = "Legacy Program Code",
                                         UniqueName = "LegacyProgramCode",
                                         HeaderStyle = { Width = Unit.Pixel(100) },
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 3,
     
                                     };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                     {
                                         DataField = "FinancialRiskISOCountrySubdivisionCode",
                                         HeaderText = "Financial Risk ISO Country Subdivision Code",
                                         UniqueName = "FinancialRiskISOCountrySubdivisionCode",
                                         HeaderStyle = { Width = Unit.Pixel(100) },
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 0,
                                     };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                     {
                                         DataField = "LineOfBusinessMarkelCode",
                                         HeaderText = "Line Of Business Markel Code",
                                         UniqueName = "LineOfBusinessMarkelCodeb",
                                         HeaderStyle = { Width = Unit.Pixel(100) },
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 2,
     
                                     };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                     {
                                         DataField = "SublineMarkelCode",
                                         HeaderText = "Subline Markel Code",
                                         UniqueName = "SublineMarkelCode",
                                         HeaderStyle = { Width = Unit.Pixel(100) },
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 3,
     
                                     };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                     {
                                         DataField = "RatingClassMarkelCode",
                                         HeaderText = "Rating Class Markel Code",
                                         UniqueName = "RatingClassMarkelCode",
                                         HeaderStyle = { Width = Unit.Pixel(100) },
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 0,
     
                                     };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                     {
                                         DataField = "CoverageTriggerCode",
                                         HeaderText = "Coverage Trigger Code",
                                         UniqueName = "CoverageTriggerCode",
                                         HeaderStyle = { Width = Unit.Pixel(100) },
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 1,
     
                                     };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                     {
                                         DataField = "RegionCode",
                                         HeaderText = "Region Code",
                                         UniqueName = "RegionCode",
                                         HeaderStyle = { Width = Unit.Pixel(100) },
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 2,
     
                                     };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                     {
                                         DataField = "LegacyAccountingUnitCode",
                                         HeaderText = "Legacy Accounting Unit Code",
                                         UniqueName = "LegacyAccountingUnitCode",
                                         HeaderStyle = { Width = Unit.Pixel(100) },
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 3,
     
                                     };
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _bounddtColumn = new GridDateTimeColumn
                                     {
                                         DataField = "PremiumFinancialEffectiveFromDate",
                                         HeaderText = "Premium Financial Effective From Date",
                                         UniqueName = "PremiumFinancialEffectiveFromDate",
                                         HeaderStyle = { Width = Unit.Pixel(100) },
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 0,
                                         DataFormatString = "{0:M/d/yyyy}",
                                     };
                _batchAdjustments.Columns.Add(_bounddtColumn);
     
                _bounddtColumn = new GridDateTimeColumn
                                     {
                                         DataField = "PremiumFinancialEffectiveToDate",
                                         HeaderText = "Premium Financial Effective To Date",
                                         UniqueName = "PremiumFinancialEffectivetoDate",
                                         HeaderStyle = {Width = Unit.Pixel(100)},
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 0,
                                         DataFormatString = "{0:M/d/yyyy}",
     
                                     };
                _batchAdjustments.Columns.Add(_bounddtColumn);
     
                _bounddtColumn = new GridDateTimeColumn
                                     {
                                         DataField = "CoverageEffectiveDate",
                                         HeaderText = "Coverage Effective Date",
                                         UniqueName = "CoverageEffectiveDate",
                                         HeaderStyle = { Width = Unit.Pixel(100) },
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 0,
                                         DataFormatString = "{0:M/d/yyyy}",
                                     };
     
                _batchAdjustments.Columns.Add(_bounddtColumn);
     
                _bounddtColumn = new GridDateTimeColumn
                                     {
                                         DataField = "CoverageExpirationDate",
                                         HeaderText = "Coverage Expiration Date",
                                         UniqueName = "CoverageExpirationDate",
                                         HeaderStyle = {Width = Unit.Pixel(100)},
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 0,
                                         DataFormatString = "{0:M/d/yyyy}",
                                     };
     
                _batchAdjustments.Columns.Add(_bounddtColumn);
                _boundColumn = new GridBoundColumn
                                     {
                                         DataField = "PolicyClaimManualAdjustmentTypeName",
                                         HeaderText = "Manual Adjustment Type Name",
                                         UniqueName = "PolicyClaimManualAdjustmentTypeName",
                                         HeaderStyle = {Width = Unit.Pixel(100)},
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 0,
                                     };
     
                _batchAdjustments.Columns.Add(_boundColumn);
     
                _boundColumn = new GridBoundColumn
                                     {
                                         DataField = "AutoGenerated",
                                         HeaderText = "Auto-Generated",
                                         UniqueName = "AutoGenerated",
                                         HeaderStyle = {Width = Unit.Pixel(100)},
                                         ItemStyle = {Width = Unit.Pixel(100)},
                                         EditFormColumnIndex = 0,
                                     };
     
                _batchAdjustments.Columns.Add(_boundColumn);
                return _policyRadGrid;
            }
        }
     }


    The grid will function in a different manner based on the access level of the user. On a 'basic user level' they will have a Add New Item/Edit Item on the parent grid and Edit, Reject(delete), Approve(Update) on the Child Grid

    The next level will be a 'Approver' role. They will NOT have Add New Item/Edit Item on the parent grid and will only have Reject(Edit) on the child. The action that the user will take in this role when rejecting an item is that they will be required to enter a comment through a user control that will be launched when the click the reject button.

    private void SubmittedBatchesRadGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        GridDataItem _dataItem = e.Item as GridDataItem;
        if (_dataItem == null) return;
     
        if (e.Item.OwnerTableView.Name == "SubmittedBatchesRadGrid_ChildGrid")
        {
            SetChildGridCommandColumns(sender, e);
            return;
        }
     
        if (_dataItem.KeyValues == "{}") { return; }
     
        SetMasterGridCommandColumns(sender, e, _dataItem);
     
    }
     
    private static void SetChildGridCommandColumns(object sender, GridItemEventArgs e)
    {
        const string _jqueryCode = "if(!$find('{0}').confirm('{1}', event, '{2}'))return false;";
        const string _confirmText = "<p>Rejecting this adjustment will mean that you will have to also reject the batch when you are done processing these items.</p><p>Are you sure you want to reject this adjustment?</p>";
        ((ImageButton)(((GridEditableItem)e.Item)["PolicyEditRecord"].Controls[0])).ImageUrl = "/controls/styles/images/editpencil.png";
        ImageButton _btnReject = (ImageButton)((GridDataItem)e.Item)["DeleteTransaction"].Controls[0];
     
        _btnReject.CommandName = "Update";
        _btnReject.ImageUrl = "/controls/styles/images/decline.png";
        _btnReject.ToolTip = "Reject this item";
        //_btnReject.Attributes["onclick"] = string.Format(_jqueryCode, ((Control)sender).ClientID, _confirmText, "Reject Adjustment");
    }
     
    private void SubmittedBatchesRadGrid_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
    {
        e.DetailTableView.EditFormSettings.EditFormType = GridEditFormType.WebUserControl;
        e.DetailTableView.EditFormSettings.UserControlName = "/Controls/RejectedAdjustmentComment.ascx";
        e.DetailTableView.EditMode = GridEditMode.PopUp;
     
        e.DetailTableView.CommandItemSettings.ShowAddNewRecordButton = false;
        GridDataItem _dataItem = e.DetailTableView.ParentItem;
        e.DetailTableView.DataSource = AdjustmentAPI.GetAdjustmentsByBatch(Convert.ToInt32(_dataItem.GetDataKeyValue("BatchID").ToString()), PolicyClaimManualAdjustmentCode);
    }


    Any thoughts as to why it's not launching the user control?




  2. Marin
    Admin
    Marin avatar
    1043 posts

    Posted 03 Nov 2011 Link to this post

    Hello Tim,

     The CommandName of the button in the custom edit column should be "Edit" not "Update". Since you need to show a user control in a popup that is related to the edit functionality of the grid. The button has to fire edit command instead of update.

    private static void SetChildGridCommandColumns(object sender, GridItemEventArgs e)
        {
            ((ImageButton)(((GridEditableItem)e.Item)["PolicyEditRecord"].Controls[0])).ImageUrl = "/controls/styles/images/editpencil.png";
            ImageButton _btnReject = (ImageButton)((GridDataItem)e.Item)["DeleteTransaction"].Controls[0];
     
            _btnReject.CommandName = "Edit";
            _btnReject.ImageUrl = "/controls/styles/images/decline.png";
            _btnReject.ToolTip = "Reject this item";
        }
     

    Best wishes,
    Marin
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top