Banca del Ceresio
Top achievements
Rank 1
Banca del Ceresio
asked on 03 Jul 2008, 07:34 AM
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
Can somebody help me with this issue?
thanx
Raphael
11 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 03 Jul 2008, 08:10 AM
Hi,
Try the following code snippet to achieve the desired scenario.
ASPX:
CS:
Thanks
Shinu.
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.
0
Banca del Ceresio
Top achievements
Rank 1
answered on 03 Jul 2008, 08:40 AM
Thank you so much! Now it works perfectelly!
best
Raphael
best
Raphael
0
Princy
Top achievements
Rank 2
answered on 03 Jul 2008, 09:34 AM
Hi Raphael,
You can also have a look at the following help article.
Accessing cells and rows
Princy.
You can also have a look at the following help article.
Accessing cells and rows
Princy.
0
EET Group
Top achievements
Rank 2
answered on 03 Dec 2008, 05:52 PM
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?
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?
0
EET Group
Top achievements
Rank 2
answered on 03 Dec 2008, 06:01 PM
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?
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?
0
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.
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.
0
EET Group
Top achievements
Rank 2
answered on 04 Dec 2008, 09:30 AM
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 :-)
We'll manage with the hard coding for now :-)
0
Christian
Top achievements
Rank 1
answered on 23 Mar 2012, 03:52 PM
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
Can't you guys just expose the property on the column wrapper??
Thanks,
Forte
0
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
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.
0
Maulin
Top achievements
Rank 1
answered on 01 Jun 2016, 11:56 AM
Can this be done on clientside?
0
Hi Maulin,
On the client-side you can achieve this by using the following CSS rule
It will target all RadInputs in edit mode InPlace.
I hope this helps.
Regards,
Galin
Telerik
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.