Hi to all,
it is possible to get the WIDTH of a RadGrid - Colum by Serverside or ClientSide!
I would like to set the WIDTH for a RadComboBox that is equal to the WIDTH to the RadGrid Column.
For visual reasons, I would like to set the width for the RadComboBox equal to column size
Thank
6 Answers, 1 is accepted
One sugestion is setting the Width of RadComboBox to "100%" so that the combobox will take the width of container accordingly.
ASPX:
| <telerik:GridTemplateColumn UniqueName="Combo"> |
| <ItemTemplate> |
| <telerik:RadComboBox ID="RadComboBox2" runat="server" Width="100%"> |
| </telerik:RadComboBox> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
Thanks,
Princy.
sorry i think my description was not the best!
My RadComboBox is not inside the RadGrid. It is outside in a RadToolBar!
Thanks
Try the following code snippet and see whether it helps.
ASPX:
| <telerik:RadToolBar ID="RadToolBar1" runat="server"> |
| <Items> |
| <telerik:RadToolBarButton runat="server" Text="Button 0"> |
| <ItemTemplate> |
| <telerik:RadComboBox ID="RadComboBox3" runat="server"> |
| <Items> |
| . . . |
| </Items> |
| </telerik:RadComboBox> |
| </ItemTemplate> |
| </telerik:RadToolBarButton> |
| . . . |
| </Items> |
| </telerik:RadToolBar> |
CS:
| int w = Convert.ToInt32(RadGrid1.MasterTableView.GetColumn("Combo").HeaderStyle.Width.Value); // Get the width of grid column |
| RadToolBarItem Item = (RadToolBarItem) RadToolBar1.FindItemByText("Button 0"); // Get the ToolBar item |
| RadComboBox combo = (RadComboBox)Item.FindControl("RadComboBox3"); // Get reference to combobox |
| combo.Width = Unit.Pixel(w); // Set width |
Thanks,
Princy.
| int w = Convert.ToInt32(RadGrid1.MasterTableView.GetColumn("Combo").HeaderStyle.Width.Value); |
Unless, until you set the width of the column explicitly, the width of the column will be 0. So, a possible suggestion for your scenario is to set the width of the grid column explicitly and then set the same width value for the RadComboBox in the aspx.
aspx:
| <telerik:GridBoundColumn DataField="ProductName" UniqueName="BoundColumn" HeaderText="BoundColumn"> |
| <HeaderStyle Width="100px" /> |
| </telerik:GridBoundColumn> |
| <telerik:RadToolBar ID="RadToolBar1" runat="server"> |
| <Items> |
| <telerik:RadToolBarButton runat="server" Text="Button"> |
| <ItemTemplate> |
| <telerik:RadComboBox ID="RadComboBox3" Width="100px" runat="server"> |
| ... |
| </telerik:RadComboBox> |
| </ItemTemplate> |
| </telerik:RadToolBarButton> |
| . . . |
| </Items> |
| </telerik:RadToolBar> |
Thanks
Princy.
Hi,
this work. BUT unfortunately it does not solve my problem.
It does not solve my problem because I can not specify the width as I do not know it?
Because of this i can not define the <HeaderStyle Width="100px" />.
That is why I have this work leave the grid. This automatically defines the optimal colum width. I hope that when the grid set the optimal width depending on the text length, that i can get it to set it for the RadComboBox!
Is there a way to get the width without define a HeaderStyle.
Regards