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

[Solved] How to return value from RadAjaxManager1_AjaxRequest ?

1 Answer 240 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Virendra
Top achievements
Rank 1
Virendra asked on 29 Jul 2009, 11:03 PM
Hi,
I have a radGrid, 
in RadGrid1_ItemDataBound, i am attaching clientside event  
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem && e.Item.IsInEditMode)
{
GridDataItem item = (GridDataItem)e.Item;
TextBox textBox = item["CompanyName"].Controls[0] as TextBox;    // Get the textbox for column CompanyName      
textBox.Attributes.Add("onFocusout", "OnRadGridCellFocusOut("+ parameters +")");
}

This client event makes an AjaxRequest when the column loose focues

function OnRadGridCellFocusOut(RowIndex, ColumnIndex)
{
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest(RowIndex + ":" + ColumnIndex);
}

In AjaxRequest Handler
protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
//do some processing to update the next column
}

after the processing, i want to update the value of next column.

for example
if Col1 is updated to IBM i will make Col2 as 'Partener'.

i was thinking if AjaxRequest can return a value to clientside caller, i could update it from there.

What is the best way to do it?

thanks
virendra


1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Jul 2009, 07:41 AM
Hello Virendra,

A suggestion is to directly pass the client ids' of the textboxes from server to client side and then perform all the operations at the client itself rather than performing several round trips. Try out the following code and see if helps meet your requirement:
c#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
 
            TextBox textBox1 = editItem["CompanyName"].Controls[0] as TextBox; 
            TextBox textBox2 = editItem["Col2UniqueName"].Controls[0] as TextBox; 
            textBox1.Attributes.Add("onFocusout""OnRadGridCellFocusOut('" + textBox1.ClientID + "','" + textBox2.ClientID + "')"); 
        } 
   } 

js:
 function OnRadGridCellFocusOut(textbox1,textbox2) 
    { 
       var text1 = document.getElementById(textbox1); 
       var text2 = document.getElementById(textbox2); 
       if(text1.value == "IBM"
           text2.value = "Partner" 
            
    } 

Thanks
Princy.
Tags
Grid
Asked by
Virendra
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or