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

[Solved] Accessing Control in EditTemplate

3 Answers 249 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Baatezu
Top achievements
Rank 2
Baatezu asked on 25 May 2009, 11:00 PM
I have a GridTemplateColumn with a RadComboBox in the EditItemTemplate. In the footer of this RCB I have some textboxes and a button.
What I need to do - Access other items in the footer of the RCB via javascript on the client side. (I need to validate one of the textboxes with a customvalidator)

I can do this with a RCB that I have designtime access to, I figured that out. :)

My first attempts were trying to find a way to access the RCB from the edit item template and get it's client ID. I can't find a way to get to the RCB that way... and that's kinda all I had.

Can anyone give me a pointer in how I can, (in my Page_Load for example), access the RCB in a GridTemplateColumn's EditItemTemplate.
If there is a RadGrid clientside method I could do this with as well, I can probably make that work.

Anything, at this point, would be much appreciated.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 May 2009, 04:14 AM
Hi,

You can check out the following code library which explains on how to access the server controls nested inside templateson the client. For this purpose a global registry that keeps control's ID is used and script for every server control is emitted which adds an item to the global registry.  On looping over all registered elements and the one that contains the required controls server ID is retrieved.
Accessing server controls in a grid template on the client

Thanks
Princy.


0
Baatezu
Top achievements
Rank 2
answered on 26 May 2009, 04:53 PM
Thank you very much for that link. It gives me a direction that I think I can make work for me. Mostly the imbeded javascript in the ItemTemplate, that should allow me to call a function and pass the values to use in the Javascript framework thingy  I'm using.

Many thanks
0
Baatezu
Top achievements
Rank 2
answered on 26 May 2009, 05:59 PM
Well... I think I encountered a problem. Which is probably why my original method wasn't working either. The grid is AJAX'd so when it loads the Edit/Insert template, the javascript isn't running. I tested by putting in an alert.
If I have a button do a post back, then the javascript runs and everything get's set up properly.

I have a usercontrol loading in the footer of teh RCB, the javascript in this usercontrol is also, not running.
If it's possible to get the javascript in either the Edit tempalte or the usercontrol to run, I can do what I am trying. Obviously I want to try and do it without disabling the ajax on the grids. 

I understand this may be a limitation on how javascript is initialized/prepared, ect, so I'm going to be disabling the ajax on the grids to continue development - but any advice on  how to get the javascript to run and keep the grids ajax'd would be much appreciated.
Tags
Grid
Asked by
Baatezu
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Baatezu
Top achievements
Rank 2
Share this question
or