Welcome Guest Search | Active Topics | Sign In | Register

Retrieve control object id from grid Options
Sheri
Posted: Monday, October 25, 2010 12:43:26 PM
Rank: Newbie
Groups: Member

Joined: 10/19/2010
Posts: 1


I need to find a controls id within a grid cell/column.
In your api I found the control.getid(), but am unable to get it to work.

My goal is to be able to resize any control within any grid to the grids column size.

What do I need to do to get this to work?

Thanks

eo_support
Posted: Monday, October 25, 2010 3:11:03 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

control.getId is for the Grid. There are no controls inside our Grid cells. If you use a CustomColumn, the control will be inside the CustomColumn's EditorTemplate and has nothing to do with grid cells or rows. If that is the case, you will need to use the following code to find out the ClientID of your control ID:

Code: C#
//Get the CustomColumn control
EO.Web.CustomColumn col = (EO.Web.CustomColumn)Grid1.Columns[0];

//Get the text box inside the CustomColumn's EditorTemplate
TextBox tb = (TextBox)col.EditorInstance.FindControl("TextBox1");

//Get the text box's client ID
string id = tb.ClientID;


The above code assumes that the first column is a CustomColumn and you have a TextBox with ID "TextBox1" inside the CustomColumn's EditorTemplate.

If you wish to do this on the client side, the code is very much the same except that you will have to write them all in one statement with ASP.NET rendering syntax:

Code: JavaScript
//Get the ClientID of the TextBox control
var id = '<%=((EO.Web.CustomColumn)Grid1.Columns[0]).EditorInstance.FindControl("TextBox1").ClientID%>';

//Get the DOM textbox object
var tb = document.getElementById(id);

//Change textbox width
tb.style.width = "100px";

You can put such code inside the column's ClientSideBeginEdit handler, then get the current column width from your handler and adjust your textbox (or any other control's width) based on the column width.

Hope this helps. Please feel free to let us know if you have any other questions.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.