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

Client Side Databinding and ItemTemplate

2 Answers 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sharad
Top achievements
Rank 1
Sharad asked on 08 Jan 2009, 03:08 PM
I have a RadGrid setup on a page bound to a collection that is initialised and bound on the page_load event. A snippet of the aspx code showing the colum setup is shown here:


 

<Columns>

 

 

 

 

<telerik:GridTemplateColumn HeaderText="&nbsp;" UniqueName="Status" HeaderStyle-Width="30px" ItemStyle-HorizontalAlign="Right">

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

This all works okay. However when I call the dataBind() method from javascript in conjuction with the OnRowDataBound handler to populate the rows (by obtaining the cell and setting the innerHTML), my grid appears is loaded as I expect BUT the style properties that I set on the Columns such as the  ItemStyle-HorizontalAlign="Right"  are no longer applied. My question is how do I set the styles if I want them retained when loading the Grid via client-side code?

More broadly, is it possible to work with ItemTemplates when working with the  client-side dataBind() without having to resort to the OnRowDataBound event?

 

2 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 10 Jan 2009, 01:59 PM
Hello Sharad,

You can try accessing the particular grid cell through the getCellByColumnUniqueName() client-side method and set its styles client side.

Give it a try and let me know if this works for you.

Regards,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Crescent
Top achievements
Rank 1
answered on 11 Jan 2009, 04:57 AM
My experience is that if you want customized columns, it's best to choose one way of binding data to the grid, either in the code-behind on page_load or in the client via dataBind(). Otherwise, you will have to duplicate any column customization on both the server (in ItemTemplates) and the client (in OnRowDataBound). Choose one or the other and make work easier on yourself.

Tags
Grid
Asked by
Sharad
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Crescent
Top achievements
Rank 1
Share this question
or