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

All I Want to Do Is Get Out of Edit Mode

6 Answers 52 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Elliott
Top achievements
Rank 2
Elliott asked on 20 Jan 2012, 10:40 PM
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?

6 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 21 Jan 2012, 05:47 AM
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
0
Elliott
Top achievements
Rank 2
answered on 23 Jan 2012, 03:10 PM
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>

0
Iana Tsolova
Telerik team
answered on 23 Jan 2012, 03:27 PM
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
0
Elliott
Top achievements
Rank 2
answered on 23 Jan 2012, 03:30 PM
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
0
Elliott
Top achievements
Rank 2
answered on 23 Jan 2012, 07:53 PM
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();
}
0
Iana Tsolova
Telerik team
answered on 24 Jan 2012, 09:39 AM
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
Tags
Ajax
Asked by
Elliott
Top achievements
Rank 2
Answers by
Iana Tsolova
Telerik team
Elliott
Top achievements
Rank 2
Share this question
or