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

Unable to set width of controls in gridtemplate column

3 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joakim
Top achievements
Rank 1
Joakim asked on 28 Jun 2016, 08:51 AM

Good morning,

 

I've got a GridTemplateColumn that has a set width (10%) and that implements both an Item- and EditItemTemplate. These templates implement asp:table(s) with colspan. The colspan of the itemtemplate is set to 2 and implements two rows, one with a label and one with two buttons.

My problem is that the buttons look slightly too big in relations to the label (see attached screendump).

 

 

I've attempted to setting the width / height in the buttons, but to no effect.

In addition to that I've attempted to set the w/h in CSS, both with a reference to the css-class through the control(s), but also through attempting to set all controls of type RadPushButton.

Still, nothing...

 

Any help would be appriciated!

 

This is the code for the GridTemplateColumn in question:

<telerik:GridTemplateColumn HeaderText="Actual Finish" AllowFiltering="False" runat="server" HeaderStyle-Width="10%" UniqueName="ActualFinish">
            <ItemTemplate>
                <table>
                    <tr>
                        <td colspan="2">
                            <telerik:RadLabel ID="RlblActualFinish" runat="server" Text='<%# Bind ("ActualFinish") %>'       UniqueName="RlblActualFinish"/>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="1">
                            <telerik:RadPushButton runat="server" ID="RpbActualFinish" Text="Now" CommandName="FinishNow" RenderMode="Auto" cssclass="radpushbutton"/>
                        </td>
 
                        <td colspan="1">
                            <telerik:RadPushButton runat="server" ID="RbtnActualPlannedFinish" Text="Planned" CommandName="FinishPlanned" RenderMode="Auto" />
                        </td>
                    </tr>
                </table>
                                                     
            </ItemTemplate>
 
            <EditItemTemplate>
                <table>
                    <tr>
                            <td colspan="12">
                        <uc2:ctrlDatetimeActivity id="ctrlActualFinishColumn" runat="server"
                            SelectedDateTime='<%# If(Eval("ActualFinish") Is DBNull.Value, Datetime.now(), Eval("ActualFinish"))%>' />
 
                            </td>
                    </tr>
                    <tr>
                            <td colspan="1">
                            <telerik:RadPushButton runat="server" ID="RbtnFinishNowIP" Text="Now" CommandName="FinishNowIP" RenderMode="Auto" />
                            </td>
                                                               
                            <td colspan="1">
                            <telerik:RadPushButton runat="server" ID="RbtnFinishPlannedIP" Text="Planned" CommandName="FinishPlannedIP" RenderMode="Auto" />
                            </td>
                            <td colspan="1">
                            </td>
                            <td colspan="1">
                            </td>
                            <td colspan="1">
                            </td>
                            <td colspan="1">
                            </td>
                            <td colspan="1">
                            </td>
                            <td colspan="1">
                            </td>
                            <td colspan="1">
                            </td>
                            <td colspan="1">
                            </td>
                            <td colspan="1">
                            </td>
                            <td colspan="1">
                            </td>
                    </tr>
                                                     
                </table>
 
            </EditItemTemplate>
 
</telerik:GridTemplateColumn>

 

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 29 Jun 2016, 01:29 PM
Hi,

You can try using the code snippet below in order to set width of the controls in gridtemplate column:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem item = (GridEditableItem)e.Item;
        RadPushButton pushBtn = (RadPushButton)item["ActualFinish"].FindControl("RpbActualFinish");
        pushBtn.Width = Unit.Pixel(50);
    }
}

For additional information about accessing controls refer to the article below:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-editinsert-mode

Regards,
Pavlina
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Joakim
Top achievements
Rank 1
answered on 29 Jun 2016, 01:39 PM

Hi,

 

I'm not sure if I was unclear, but the buttons I would like to resize are the ones in the ItemTemplate, not the ones in the EditItemTemplate.

Also, can you use percentage-based units (unit.percentage or something of the sort) instead of the unit.pixel?

 

Thanks!     

0
Pavlina
Telerik team
answered on 30 Jun 2016, 04:19 PM
Hi,

To access a control from the ItemTemplate try using the following code:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
     if (e.Item is GridDataItem)
     {
        GridDataItem item = (GridDataItem)e.Item;
        RadPushButton pushBtn = (RadPushButton)item["ActualFinish"].FindControl("RpbActualFinish");
    }
}

Regards,
Pavlina
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Joakim
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Joakim
Top achievements
Rank 1
Share this question
or