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

RadInputManager ClientEvents for GridBoundColumns?

5 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Carlos Contreras
Top achievements
Rank 1
Carlos Contreras asked on 19 Jul 2010, 07:33 PM

Hi everybody!

I was following this demo, to understand how to implement RadInput's properties and functionallity to GridBoundColumns TextBoxes, and I found it very interesting.

However in the demo there isn't an example about how to use ClientEvents (like OnKeyPress or OnBlur) for that scenario.

I would like to do something like this OnKeyPress with a couple columns inside a RadGrid, but nothing seems to happen. I even include an alert function inside the AlphabetOnly function, but it doesn´t show.

Is it possible to use RadIpuntManager's ClientEvents in these cases?


Thanks a lot!

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Jul 2010, 02:16 PM
Hello Carlos,

Check out the following code snippet which shows how to implement 'OnKeyPress' event to GridBoundColumn.

ASPX:
<telerik:RadInputManager ID="RadInputManager1" runat="server">
    <telerik:TextBoxSetting BehaviorID="TextBoxBehavior1" InitializeOnClient="false">
         <ClientEvents OnKeyPress="OnKeyPress" />
    </telerik:TextBoxSetting>
 </telerik:RadInputManager>
 <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource3" OnItemCreated="RadGrid1_ItemCreated">
    <MasterTableView runat="server" EditMode="EditForms" DataSourceID="SqlDataSource3" >
        <Columns>
           <telerik:GridBoundColumn DataField="CategoryID" HeaderText="CategoryID" UniqueName="CategoryID">
            </telerik:GridBoundColumn>
         </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
       if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
        {
            GridEditFormItem editItem = (GridEditFormItem)e.Item;
            TextBox txt = (TextBox)editItem["CategoryID"].Controls[0];
            TextBoxSetting textBoxSetting = (TextBoxSetting)RadInputManager1.GetSettingByBehaviorID("TextBoxBehavior1");
            textBoxSetting.TargetControls.Add(new TargetInput(txt.UniqueID, true));
        }
    }

Java Script:
<script type="text/javascript">
    function OnKeyPress(sender, args) {
        alert(args.get_keyCharacter());
    }
</script>

Thanks,
Princy.
0
Carlos Contreras
Top achievements
Rank 1
answered on 20 Jul 2010, 04:15 PM
Thanks for your reply Princy!

Actually, my code looks a lot like yours, but I'm still having problems with the OnKeyPress event!

By the way, my RadGrid is within a RadAjaxPanel. Does that matter? I mean, does that affect the RadIpuntManager's ClientEvents behavior?


Thanks!
0
Carlos Contreras
Top achievements
Rank 1
answered on 21 Jul 2010, 11:46 PM
Maybe Princy is very busy! :(
0
Accepted
Princy
Top achievements
Rank 2
answered on 22 Jul 2010, 08:40 AM
Hello Carlos,

I believe the RadInputManager is placed outside the RadAjaxPanel in your case. Try adding RadInputManager and RadGrid inside RadAjaxPanel and see whether it works.

ASPX:
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
  <telerik:RadInputManager ID="RadInputManager1" runat="server">
       <telerik:TextBoxSetting BehaviorID="TextBoxBehavior1" InitializeOnClient="false">
           <ClientEvents OnKeyPress="OnKeyPress" />
       </telerik:TextBoxSetting>
   </telerik:RadInputManager>
   <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource3" OnItemCreated="RadGrid1_ItemCreated">
     <MasterTableView runat="server" EditMode="EditForms" DataSourceID="SqlDataSource3">
       <Columns>
         <telerik:GridBoundColumn DataField="CategoryID" HeaderText="CategoryID" UniqueName="CategoryID">
         </telerik:GridBoundColumn>
       </Columns>
      </MasterTableView>
    </telerik:RadGrid>
 </telerik:RadAjaxPanel>

Thanks,
Princy.
0
Carlos Contreras
Top achievements
Rank 1
answered on 22 Jul 2010, 03:02 PM

DONE!!!

I can't believe I couldn't figured out myself! Shame on me! :P


Thanks a lot Princy!
Tags
Grid
Asked by
Carlos Contreras
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Carlos Contreras
Top achievements
Rank 1
Share this question
or