Esempio n. 1
0
        /// <summary>
        /// Handles the OnItemDataBound event of the rgServiceLevelClient control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.GridItemEventArgs"/> instance containing the event data.</param>
        protected void rgServiceLevelClient_OnItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                var editedItem = e.Item as GridEditableItem;
                var editMan    = editedItem.EditManager;

                ((TableRow)editedItem["ID"].Parent).CssClass = "hidden";
                var idColumnEditor = (GridTextBoxColumnEditor)(editMan.GetColumnEditor("ID"));
                if (string.IsNullOrEmpty(idColumnEditor.TextBoxControl.Text))
                {
                    idColumnEditor.TextBoxControl.Text = Guid.NewGuid().ToString();
                    if (e.Item.OwnerTableView.Name != "ServiceLevelContact")
                    {
                        var clientServiceLevel =
                            (GridDropDownColumnEditor)(editMan.GetColumnEditor("ClientServiceLevelID"));
                        clientServiceLevel.SelectedValue = ServiceLevel.ID.ToString();
                    }
                }

                if (e.Item.OwnerTableView.Name != "ServiceLevelContact")
                {
                    ((TableRow)editedItem["ServiceLevelID"].Parent).CssClass = "hidden";
                    var serviceLevelColumnEditor = (GridTextBoxColumnEditor)(editMan.GetColumnEditor("ServiceLevelID"));
                    serviceLevelColumnEditor.TextBoxControl.Text = ServiceLevel.ID.ToString();

                    var startDateTimeEditor =
                        (GridDateTimeColumnEditor)editedItem.EditManager.GetColumnEditor("StartDate");
                    startDateTimeEditor.PickerControl.Width    = new Unit(50, UnitType.Pixel);
                    startDateTimeEditor.PickerControl.CssClass = "date-picker";
                    var endDateTimeEditor = (GridDateTimeColumnEditor)editedItem.EditManager.GetColumnEditor("EndDate");
                    endDateTimeEditor.PickerControl.Width    = new Unit(50, UnitType.Pixel);
                    endDateTimeEditor.PickerControl.CssClass = "date-picker";
                }
                else
                {
                    ((TableRow)editedItem["ServiceLevelClientID"].Parent).CssClass = "hidden";
                    ((TableRow)editedItem["ContactEmail"].Parent).CssClass         = "hidden";

                    var serviceLevelClientColumnEditor = (GridTextBoxColumnEditor)(editMan.GetColumnEditor("ServiceLevelClientID"));
                    serviceLevelClientColumnEditor.TextBoxControl.Text = ServiceLevelClientId.ToString();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the OnDataBound event of the rgServiceLevelClient control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.GridItemEventArgs"/> instance containing the event data.</param>
        protected void rgServiceLevelClient_OnItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                var editedItem = e.Item as GridEditableItem;
                var editMan    = editedItem.EditManager;

                var idColumnEditor = (GridTextBoxColumnEditor)(editMan.GetColumnEditor("ID"));
                if (string.IsNullOrEmpty(idColumnEditor.TextBoxControl.Text))
                {
                    idColumnEditor.TextBoxControl.Text = Guid.NewGuid().ToString();
                }


                if (e.Item.OwnerTableView.Name != "ServiceLevelContact")
                {
                    var serviceLevelColumnEditor = (GridTextBoxColumnEditor)(editMan.GetColumnEditor("ServiceLevelID"));
                    serviceLevelColumnEditor.TextBoxControl.Text = ServiceLevel.ID.ToString();

                    ((GridDropDownListColumnEditor)(editMan.GetColumnEditor("ClientID"))).ComboBoxControl.Filter = RadComboBoxFilter.Contains;

                    var editor    = (GridNumericColumnEditor)editMan.GetColumnEditor("CountOfServiceContacts");
                    var cell      = (TableCell)editor.NumericTextBox.Parent;
                    var validator = new RequiredFieldValidator
                    {
                        ControlToValidate = editor.NumericTextBox.ID,
                        ErrorMessage      = "*",
                        ForeColor         = Color.Red
                    };
                    cell.Controls.Add(validator);
                }
                else
                {
                    var serviceLevelClientColumnEditor = (GridTextBoxColumnEditor)(editMan.GetColumnEditor("ServiceLevelClientID"));
                    serviceLevelClientColumnEditor.TextBoxControl.Text = ServiceLevelClientId.ToString();

                    ((TableRow)editedItem["ContactEmail"].Parent).CssClass = "hidden";

                    ((GridDropDownListColumnEditor)(editMan.GetColumnEditor("ContactID"))).ComboBoxControl.Filter = RadComboBoxFilter.Contains;
                    ((GridTextBoxColumnEditor)(editMan.GetColumnEditor("Comment"))).TextBoxControl.TextMode       = TextBoxMode.MultiLine;
                }
            }
        }