Solved

Applying the same width to all textboxes in edit mode (telerik radgrid)

Posted on 2013-06-25
5
558 Views
Last Modified: 2013-09-02
Hello!

When I enter edit mode in a Telerik radgrid I end up with all the textboxes beeing in different width.

I thought of solving this, by looping through all the items that is beeing edited and set them to System.Web.UI.WebControls.Unit.Pixel(300); to change the size.

I have tried with a loop looking something like below, but obviously this will yield error,

Any idea what to do to make them into the same size?

foreach (GridEditFormItem EdItem in rgRelMaterial.Columns)
  {
        EdItem.Width = System.Web.UI.WebControls.Unit.Pixel(300);
  }
0
Comment
Question by:clooak
  • 3
  • 2
5 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 39274771
foreach (Telerik.Web.UI.GridColumn c in rgRelMaterial.MasterTableView.RenderColumns)
            {
                c.HeaderStyle.Width = Unit.Pixel(300);
            }
0
 

Author Comment

by:clooak
ID: 39274831
I thought of that as first aswell, but the problem is that Telerik differs the textbox in the grid and the edit items.

When I use the code you gave, it will only change the textboxes in normal view (before and after edit) not the textboxes in edit mode.

So I need to determine somehow if the textbox found is in editmode or not, so that I don't alter the normal textboxes.

Tricky  I know :(
0
 

Accepted Solution

by:
clooak earned 0 total points
ID: 39274860
I think I sorted it out, by using onColumnCreated event (since the edit textboxes are created on the fly)

Something like this should work

protected void rgRelMaterialLoad_ColumnCreated(object sender, Telerik.Web.UI.GridColumnCreatedEventArgs e)
        {

 if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {   
         // Insert code here to edit the width of the Column added.
    }
}

Open in new window

0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 39275718
Test it and if it is feel free to accept your own answer as the solution :-).  Good knowledge for anyone else coming through.
0
 

Author Closing Comment

by:clooak
ID: 39457789
Solved it myself
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question