Unable to set width of controls in gridtemplate column

4 posts, 0 answers
  1. Joakim
    Joakim avatar
    5 posts
    Member since:
    Apr 2016

    Posted 28 Jun Link to this post

    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>

     

  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 29 Jun Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Joakim
    Joakim avatar
    5 posts
    Member since:
    Apr 2016

    Posted 29 Jun in reply to Pavlina Link to this post

    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!     

  5. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 30 Jun Link to this post

    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.
Back to Top