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

RadInputManager - Integration with RadGrid Problem

4 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Delvis
Top achievements
Rank 1
Delvis asked on 18 Jan 2015, 06:19 AM
I have a "RadGrid" for Editing Data.

I have filtering enabled.

I perform validations using the "RadInputManager".

When I try to update the data happens to me what I show in the picture attached.

How I can solve this?

I add the code "aspx" to show the example:

<telerik:RadAjaxManager runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" UpdatePanelCssClass="" />
                <telerik:AjaxUpdatedControl ControlID="RadInputManager1" UpdatePanelCssClass="" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    <Scripts>
        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js">
        </asp:ScriptReference>
        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js">
        </asp:ScriptReference>
        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js">
        </asp:ScriptReference>
    </Scripts>
</telerik:RadScriptManager>
        <telerik:RadInputManager ID="RadInputManager1" runat="server">
    <telerik:TextBoxSetting InitializeOnClient="False" ErrorMessage="Required!" Validation-IsRequired="True" Validation-ValidateOnEvent="Submit">
        <TargetControls>
            <telerik:TargetInput ControlID="RadGrid1" />
        </TargetControls>
    </telerik:TextBoxSetting>
</telerik:RadInputManager>

<telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" AutoGenerateEditColumn="True" CellSpacing="0" DataSourceID="LinqDataSource1" EnableHeaderContextFilterMenu="True" EnableHeaderContextMenu="True" GridLines="None">
    <MasterTableView CommandItemDisplay="Top" DataKeyNames="RolId" DataSourceID="LinqDataSource1" EditMode="InPlace">
        <Columns>
            <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name" UniqueName="Name">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description" UniqueName="Description">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
<asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="WebApplication1.DataClasses1DataContext" EntityTypeName="" TableName="Rol">
</asp:LinqDataSource>

4 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 21 Jan 2015, 11:30 AM
Hi Delvis,

The behavior that you are observing is rather expected, because when you include the RadGrid in the TargetControls collectiong of the RadInputManager, every TextBox control within the RadGrid will be handled by the RadInputManager, including the filter editors. 

If you want to include only specific controls you could take a look at the approach demonstrated in the following online demo:
Hope this helps.


Best Regards,
Konstantin Dikov
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
Delvis
Top achievements
Rank 1
answered on 21 Jan 2015, 05:05 PM
Hi Konstantin, 

I appreciate your response on this, but I'm really looking for ways to simplify this process validation declaratively as possible. 

There is no simple way for example using the "ValidationGroup" property ?. Of course, for this the "GridBoundColumn" column must accept the property as well.

<telerik:RadInputManager ID="RadInputManager1" runat="server">

   
<telerik:TextBoxSetting ErrorMessage="Required!" Validation-IsRequired="True"

Validation-ValidateOnEvent="Submit"

Validation-ValidationGroup="toValidate">

        <TargetControls>

            <telerik:TargetInput ControlID="RadGrid1" />

        </TargetControls>

   
</telerik:TextBoxSetting>

</telerik:RadInputManager>

Thank You, 

Delvis
0
Konstantin Dikov
Telerik team
answered on 26 Jan 2015, 12:01 PM
Hello Delvis,

There is no easy way for accomplish such result and you will have to manually find all TextBox controls within the OnItemCreated event for example and set the ValidationGroup property of those controls.

You could use the same approach as demonstrated in our online demo.


Regards,
Konstantin Dikov
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
Delvis
Top achievements
Rank 1
answered on 24 Feb 2015, 08:54 PM
I inherited from "GridBoundColumn" and "RadInputManager" in order to validate only controls that have the same "ValidationGroup" and everything works as intended. But I would use the "ValidationGroup" of "TextBoxSetting", "NumericTextBoxSetting" etc. property; but putting that value, validation functionality does not work. Any ideas ?. Thank You.

My code:

public class ZeusGridBoundColumn : GridBoundColumn
    {
        [Category("Behavior")]
        [DefaultValue("")]
        [Description("Gets or sets the name of the validation group to wich this setting belongs.")]
        [NotifyParentProperty(true)]
        public virtual String ValidationGroup
        {
            get
            {
                return (String)(ViewState["ValidationGroup"] ?? String.Empty);
            }
            set
            {
                ViewState["ValidationGroup"] = value;
            }
        }

        public override void InitializeCell(TableCell cell, int columnIndex, GridItem inItem)
        {
            base.InitializeCell(cell, columnIndex, inItem);

            if (inItem.IsDataBound && inItem.IsInEditMode && this.DataField.Length > 0)
            {
                if (this.CurrentColumnEditor is GridTextBoxColumnEditor)
                    ((GridTextBoxColumnEditor)this.CurrentColumnEditor).TextBoxControl.ValidationGroup = this.ValidationGroup;
                if (this.CurrentColumnEditor is GridNumericColumnEditor)
                    ((GridNumericColumnEditor)this.CurrentColumnEditor).NumericTextBox.ValidationGroup = this.ValidationGroup;
            }
        }

        public override GridColumn Clone()
        {
            var res = new ZeusGridBoundColumn();
            res.CopyBaseProperties(this);

            return res;
        }
    }

public class ZeusRadInputManager : RadInputManager
    {
        [Category("Behavior")]
        [DefaultValue("")]
        [Description("Gets or sets the name of the validation group to wich this setting belongs.")]
        [NotifyParentProperty(true)]
        public virtual String ValidationGroup
        {
            get
            {
                return (String)(ViewState["ValidationGroup"] ?? String.Empty);
            }
            set
            {
                ViewState["ValidationGroup"] = value;
            }
        }

        protected override void OnInputSettingCreating(InputSettingCreatingEventArgs args)
        {
            base.OnInputSettingCreating(args);

            args.Canceled = this.ValidationGroup != args.TextBox.ValidationGroup;
        }
    }
Tags
Grid
Asked by
Delvis
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Delvis
Top achievements
Rank 1
Share this question
or