I am dynamically creating templated columns which is determined by the 'Data Type'
gvMC.Rows(i).Cells.FromKey("Response").Value = ctrlString
Where ctrlString can be ie. "<input type='text' name='header' size='50' />" OR "<textarea name='comments' rows='3' cols='50'>" etc..
The problem with these controls in the grid is that they do not function properly. I cannot press the 'delete' or 'spacebar' in the text control
and in the textArea control i sometimes cannot type without holding the mouse button down. Its as if the grid cell click is overriding the fact that the Html control has focus..
What can I disable in the grid to get these controls to function normally? Do i need javascript to set focus to the Html controls?
Thanks ,
MC
If putting the item inside a templated column hasn't helped, you should take this to developer support. Your case might be a case that the grid doesn't handle and developer support will be able to forward it on to be looked at.
With the help of the last reply by Helen, I am able to add HTML control dynamically, say I have added one HTML Button, but still I am not able to call javascript function on clicking of that button. I added 'onclick' attribute to the button dynamically and tried to call simple alert message. It seems button is getting clicked but it does not respond to 'onclick' event.
If I add html control (e.g. Button) design time using template column, and try to call simple javascript alert message box, even then it does not respond to javascript onclick event.
I have gone through all the replies related to this post 'HTML controls in ultrawebgrid', but issue has not been properly addressed.
Could you please tell me any way to call javascript function on 'onclick' event of HTML Button inside grid cell. If possible could you provide sample code for it.
Just setting the column as a templated column wouldn't be enough. You would actually need to use the templating features to put the controls into the cells.
If you're creating your columns at runtime, you can also create the templates dynamically at runtime. There are some examples of how to do that in the knowledge base:
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=3890
Thanks, but that's for creating the columns at design time . I'm creating each HTML control dynamically based on another column.
The only problem I'm having now is with the text area control.
gvMC.Rows(i).Cells.FromKey("Response").Value ="<textarea name='comments' rows='3' cols='50' />"; Just about every mouse click on the control is getting overridden by the grid's code - which moves focus outside the txt area not allowing the user to type. Turning on the 'Templated Column' property on that col does not change the overriding code
You'll need to use a templated column to display the textbox. The grid's activation code captures most of the mouse and keyboard events and uses them to do navigation and text entry in the grid. It has some special code to exclude elements inside a templated column from this logic.
You can find out about column templates here: http://help.infragistics.com/Help/NetAdvantage/NET/2007.3/CLR2.0/html/WebGrid_Using_Column_Templates.html
Helen