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

Adding onclientblur event on griddropdownlistcolumneditor?

5 Answers 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AereoN
Top achievements
Rank 1
AereoN asked on 10 Dec 2009, 10:06 AM
Is there any way to add event to the griddropdownlistcolumneditor?
I'm implementing the double click edit feature on to the grid.
Instead of using buttons or other row clicks, I would like to use this event to trigger the update of the row.
Can someone show me the direction to achieve this?

Thanks.

5 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 10 Dec 2009, 11:55 AM
Hi AereoN,

You can access the DropDownListEditor from the code behind and add an attribute as shown:
c#:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)   
    {   
        if(e.Item is GridEditableItem && e.Item.IsInEditMode)   
        {               
            GridEditableItem editedItem = (GridEditableItem)e.Item;   
            GridEditManager editMan = editedItem.EditManager;   
            GridDropDownListColumnEditor editor = (GridDropDownListColumnEditor)(editMan.GetColumnEditor("DropdownColumnUniqueName"));             
            RadComboBox combo1 = editor.ComboBoxControl;   
            ddList.OnClientBlur = "OutofFocus"
        }   
    }   

js:
function OutofFocus(sender , eventArgs) 
    { 
     alert("Out of Focus!"); 
    } 

Thanks
Princy.
0
AereoN
Top achievements
Rank 1
answered on 11 Dec 2009, 02:00 AM
Thanks for the solution.
That was what I'm looking for :)
0
AereoN
Top achievements
Rank 1
answered on 15 Dec 2009, 03:51 AM
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
            if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
            { 
                GridEditableItem editedItem = (GridEditableItem)e.Item; 
                GridEditManager editManager = editedItem.EditManager; 
                GridNumericColumnEditor editor = (GridNumericColumnEditor)(editManager.GetColumnEditor("Amount")); 
 
                RadNumericTextBox numericbox = editor.NumericTextBox; 
                //numericbox.Attributes.Add("onclientblur", "alert('testing')"); 
                numericbox.EnableEmbeddedSkins = false
                numericbox.Skin = "Short"
                numericbox.Text = "900000"
                numericbox.Focus(); 
            } 
I'm using the code above which is similar to the one you shown for the radcombobox.
However in this case, the numeric textbox cant be set skin.
The text does inherit 900000(testing purpose) but the skin still remains as default.
Am I missing something here?

On a side note: How do I add onclientblur onto this control?
The intellisense doesnt show onClientBlur event.
0
Accepted
Princy
Top achievements
Rank 2
answered on 15 Dec 2009, 07:24 AM
Hello AereoN,

You can set the skin directly in the column mark up as shown below:
css:
<telerik:GridNumericColumn HeaderText="Amount" DataField="Amount" UniqueName="Amount"
    <ItemStyle CssClass="RadInput_CustomSkin" />                         
</telerik:GridNumericColumn> 

And here's the code to add an onblur client event to the NumericTextBox:
c#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem editedItem = (GridEditableItem)e.Item; 
            GridEditManager editManager = editedItem.EditManager; 
            GridNumericColumnEditor editor = (GridNumericColumnEditor)(editManager.GetColumnEditor("Amount")); 
            RadNumericTextBox numericbox = editor.NumericTextBox; 
            numericbox.ClientEvents.OnBlur = "onclientblur";  
            numericbox.Text = "900000"
            numericbox.Focus(); 
        } 
   } 

js:
 function onclientblur() 
   {       
     alert('testing'
   } 

Thanks
Princy.
0
AereoN
Top achievements
Rank 1
answered on 15 Dec 2009, 07:27 AM
Hi Princy,

Thanks once again for the solution.
Tags
Grid
Asked by
AereoN
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
AereoN
Top achievements
Rank 1
Share this question
or