All I Want to Do Is Get Out of Edit Mode

7 posts, 0 answers
  1. Elliott
    Elliott avatar
    392 posts
    Member since:
    May 2010

    Posted 20 Jan 2012 Link to this post

    so I wired up a OnBlur client event on the only column in the Edit Mode not read-only
    the function fires well and good and triggers an Ajax request which works then - nothing

        <telerik:RadCodeBlock ID="rcBlock" runat="server">
    <script type="text/javascript">
    <!--
    function rntbQty_OnBlur(sender, eventArgs) {
        alert('clear edit item');
        var theMan = $find("<%= raManager.ClientID %>");
        theMan.ajaxRequest("CloseEdits");
    }
    -->
    </script>
    </telerik:RadCodeBlock>
     
    <telerik:RadAjaxManager ID="raManager" OnAjaxRequest="raManager_AjaxRequest" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgEditOrder">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgEditOrder" />
                    <telerik:AjaxUpdatedControl ControlID="rtbStart1" />
                    <telerik:AjaxUpdatedControl ControlID="rtbEnd1" />
                    <telerik:AjaxUpdatedControl ControlID="rtbStart2" />
                    <telerik:AjaxUpdatedControl ControlID="rtbEnd2" />
                    <telerik:AjaxUpdatedControl ControlID="rtbStart3" />
                    <telerik:AjaxUpdatedControl ControlID="rtbEnd3" />
                    <telerik:AjaxUpdatedControl ControlID="txtStoreHidden" />
                    <telerik:AjaxUpdatedControl ControlID="txtChain" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    the column
    <telerik:GridTemplateColumn UniqueName="Qty" HeaderText="Cases" DataField="Qty" DataType="System.Int32" Aggregate="Sum" >
        <ItemTemplate>
            <asp:Label ID="lblQty" Text='<%# Bind("Qty") %>' Width="32px" runat="server" />
        </ItemTemplate>
        <EditItemTemplate>
            <telerik:RadNumericTextBox ID="rntbQty" DBValue='<%# Eval("Qty") %>' OnTextChanged="rntbQty_TextChanged" MinValue="0" MaxValue="99999" MaxLength="5" AutoPostBack="True" Width="32px" runat="server">                    
                <NumberFormat DecimalDigits="0" GroupSeparator="" />
                <ClientEvents OnBlur="rntbQty_OnBlur" />
            </telerik:RadNumericTextBox>
        </EditItemTemplate>
        <HeaderStyle Width="32px" />
    </telerik:GridTemplateColumn>

    protected void raManager_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        foreach (GridItem gItem in rgEditOrder.EditItems)
        {
            if (gItem is GridEditableItem)
            {
                GridEditableItem geItem = (GridEditableItem)gItem;
                geItem.Edit = false;
            
        }
        rgEditOrder.Rebind();
    }
    why won't it work?
  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 20 Jan 2012 Link to this post

    Hello Marianne,

    You need to add an ajax setting where the RadAjaxManager updates the grid. Because when you are invoking ajax request by calling the ajaxRequest() client-side event, the ajax initiator of this request is the RadAjaxManager. And if you have not specified which controls should the manager update, nothing will be changed on the page, though the server code is executed properly.

    Greetings,
    Iana Tsolova
    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. Elliott
    Elliott avatar
    392 posts
    Member since:
    May 2010

    Posted 23 Jan 2012 Link to this post

    I thought I had
    <telerik:RadAjaxManager ID="raManager" OnAjaxRequest="raManager_AjaxRequest" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgEditOrder">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgEditOrder" />
                    <telerik:AjaxUpdatedControl ControlID="rtbStart1" /> 
                    <telerik:AjaxUpdatedControl ControlID="rtbEnd1" />
                    <telerik:AjaxUpdatedControl ControlID="rtbStart2" /> 
                    <telerik:AjaxUpdatedControl ControlID="rtbEnd2" />
                    <telerik:AjaxUpdatedControl ControlID="rtbStart3" /> 
                    <telerik:AjaxUpdatedControl ControlID="rtbEnd3" />
                    <telerik:AjaxUpdatedControl ControlID="txtStoreHidden" />
                    <telerik:AjaxUpdatedControl ControlID="txtChain" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

  4. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 23 Jan 2012 Link to this post

    Hi Marianne,

    Try modifying the ajax settings as below and you'll have it:
    <telerik:RadAjaxManager ID="raManager" OnAjaxRequest="raManager_AjaxRequest" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="raManager">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgEditOrder" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="rgEditOrder">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgEditOrder" />
                    <telerik:AjaxUpdatedControl ControlID="rtbStart1" /> 
                    <telerik:AjaxUpdatedControl ControlID="rtbEnd1" />
                    <telerik:AjaxUpdatedControl ControlID="rtbStart2" /> 
                    <telerik:AjaxUpdatedControl ControlID="rtbEnd2" />
                    <telerik:AjaxUpdatedControl ControlID="rtbStart3" /> 
                    <telerik:AjaxUpdatedControl ControlID="rtbEnd3" />
                    <telerik:AjaxUpdatedControl ControlID="txtStoreHidden" />
                    <telerik:AjaxUpdatedControl ControlID="txtChain" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>


    Greetings,
    Iana Tsolova
    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
  5. Elliott
    Elliott avatar
    392 posts
    Member since:
    May 2010

    Posted 23 Jan 2012 Link to this post

    I'll give it a try
    thanks!
    if I get it to work do you want me to make a sample?  I can't be the only person to need the functionality


    I tried it - doesn't fix it
  6. Elliott
    Elliott avatar
    392 posts
    Member since:
    May 2010

    Posted 23 Jan 2012 Link to this post

    as the saying goes, there is more than one way to skin a cat
    function rntbQty_OnBlur(sender, eventArgs) {
        var theGrid = $find("<%= rgEditOrder.ClientID %>").get_masterTableView();
        if (theGrid != null) {
            theGrid.fireCommand("CancelAll", "");
            }

    put the control in focus
    <telerik:RadGrid ID="rgEditOrder" EnableLinqExpressions="false" OnNeedDataSource="rgEditOrder_NeedDataSource" OnItemCreated="rgEditOrder_ItemCreated" OnItemCommand="rgEditOrder_ItemCommand" ShowFooter="True" Skin="Sunset" runat="server">

    protected void rgEditOrder_ItemCreated(object source, GridItemEventArgs e)
    {
        GridEditableItem geItem;
        TableCell tCell;
        RadNumericTextBox rntbQty;
     
        if (e.Item.IsInEditMode)
        { }
        else
        {
            return;
        }
        if (e.Item is GridEditableItem)
        { }
        else
        {
            return;
        }
     
        // go get the Qty textbox (using hard-coded cell number)
        // and set focus to it
        // this makes closing the edit easier
        geItem = (GridEditableItem)e.Item;
        tCell = geItem.Cells[7];
        rntbQty = (RadNumericTextBox) tCell.FindControl("rntbQty");
        if (rntbQty == null)
        { return; }
        rntbQty.Focus();
    }
  7. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 24 Jan 2012 Link to this post

    Hello Marianne,

    Thank you for sharing your finding and the sample code with the community!

    All the best,
    Iana Tsolova
    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
Back to Top