GridNumericColumn textbox width

12 posts, 0 answers
  1. Banca del Ceresio
    Banca del Ceresio avatar
    11 posts
    Member since:
    Jun 2008

    Posted 03 Jul 2008 Link to this post

    Hi everybody, I have a little problem, I'm using the inlines edit mode for my radgrid, I can't figure out how I can set the width of the generated textbox in my GridNumericColumn. The textbox is alwas to big and I can't find the property to set it smaller.

    Can somebody help me with this issue?

    thanx

    Raphael
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Jul 2008 Link to this post

    Hi,

    Try the following code snippet to achieve the desired scenario.


    ASPX:
    <telerik:GridNumericColumn  UniqueName="NumCol" HeaderText="NumCol" DataField="NumCol" ></telerik:GridNumericColumn> 

    CS:
     protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
            if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) 
            { 
                GridEditableItem edititem = (GridEditableItem)e.Item; 
                RadNumericTextBox numtxtbx = (RadNumericTextBox)edititem["NumCol"].Controls[0]; 
                numtxtbx.Width = Unit.Pixel(50); 
            } 
            
        } 


    Thanks
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Banca del Ceresio
    Banca del Ceresio avatar
    11 posts
    Member since:
    Jun 2008

    Posted 03 Jul 2008 Link to this post

    Thank you so much! Now it works perfectelly!

    best

    Raphael
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Jul 2008 Link to this post

    Hi Raphael,

    You can also have  a look at the following help article.
    Accessing cells and rows

    Princy.
  6. EET Group
    EET Group avatar
    28 posts
    Member since:
    Aug 2007

    Posted 03 Dec 2008 Link to this post

    I am having this issue as well, but firstly I really don't see why you thought it necessary to hardcode a style="width: 125px" into this control/column form? It makes it impossible to CSS alter it in any way - imho this is a really BAD implementation, and even different from your other column types, which doesn't do this kind of hard code to input fields.

    That said, your solution/hack is working ok - until a post back happens. I have a button that does at simple OnClick, and then the ItemDataBound is not trigged, and the NumericField expands again.

    Do you have an improvement of the hack, or another suggestion how to keep the Numeric field to a width of i.e. 65 pixels?
  7. EET Group
    EET Group avatar
    28 posts
    Member since:
    Aug 2007

    Posted 03 Dec 2008 Link to this post

    I "solved" this myself, by changing the code above to run on ItemCreated instead.

    Still think it's a poor choice to hard code styles into controls, without respecting ItemStyle-Width or similar setting. Perhaps a kind Telerik staff could briefly explain, or perhaps tell if this is something that could be changed in an upcoming release?
  8. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 04 Dec 2008 Link to this post

    Hello Ole,

    125px is the default width of ordinary asp:TextBoxes in Internet Explorer, that's why we have used this number. Setting the width style explicitly is required by the more complex HTML code, which our textboxes have (which in turn is implied by their features and behavior).

    Recently we optimized the rendering of our textboxes, so in some cases it became a lot simpler and the inline width style is not required, however, we have left it for backwards compatibility and to avoid scenarios in which one has two Telerik textboxes one by the other and suddenly they appear with different dimensions due to inherited styles.

    At any rate, we may reconsider changing this in the future.

    Regards,
    Dimo
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  9. EET Group
    EET Group avatar
    28 posts
    Member since:
    Aug 2007

    Posted 04 Dec 2008 Link to this post

    Thanks for the reply - I figured it would have something to do with the extended functionality of the Numeric textbox.

    We'll manage with the hard coding for now :-)
  10. Christian
    Christian avatar
    3 posts
    Member since:
    Jan 2011

    Posted 23 Mar 2012 Link to this post

    I just ran into this same issue. Seems pretty overkill for just setting the size of the text box in edit/insert mode when using the GridNumericColumn.

    Can't you guys just expose the property on the column wrapper??

    Thanks,
    Forte
  11. Galin
    Admin
    Galin avatar
    526 posts

    Posted 28 Mar 2012 Link to this post

    Hello Christian,

    There is a possibility of scenario, in which two or more inputs or other elements are rendered inside the GridColumns. Therefore, I can suggest you to set the property CssClass to this GridColum and style the numeric text box inside.

    I hope this helps.

    Greetings,
    Galin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  12. Maulin
    Maulin avatar
    3 posts
    Member since:
    Mar 2016

    Posted 01 Jun in reply to Shinu Link to this post

    Can this be done on clientside?
  13. Galin
    Admin
    Galin avatar
    526 posts

    Posted 06 Jun Link to this post

    Hi Maulin,

    On the client-side you can achieve this by using the following CSS rule
    .rgEditRow .RadInput {
        width: 100px;
    }

    It will target all RadInputs in edit mode InPlace.

    I hope this helps.

    Regards,
    Galin
    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
UI for ASP.NET Ajax is Ready for VS 2017