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

SelectedRows and Auto Row Height

26 Answers 551 Views
GridView
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 13 Dec 2007, 12:58 PM
hi,

1. In my case, I need to update the cells using API in the selectedrows, but when i update anyone cell, the collection (selectedrow) will be change to null, and fire some error.

how can i solve this problem ?

2. Can I set a cell be a auto row height, when i set the wraptext is true ?

26 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 14 Dec 2007, 12:05 PM
Hello James,

Thank you for writing us.

Yes, currently the SelectedRows collection is cleared when a cell value is changed. Unfortunately, we can not change this behavior at the moment. We will fix this issue in one of our future releases.

RadGridView does not support auto row height feature, but it is in our TODO list and we will implement it as soon as possible.

Don't hesitate to contact us if you have other questions.

Regards,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jim Moore
Top achievements
Rank 1
answered on 14 Jan 2008, 12:21 AM
I'm running into the same problem - I need row auto-height for wrapped columns.

Is there a way to fake it manually on a row render event?

Jim
0
Jack
Telerik team
answered on 14 Jan 2008, 01:43 PM
Hi Jim Moore,

Unfortunately, this effect can not be achieved at this time. The implementation of word wrapping at a low level in our framework is on our todo list. However, its development is not scheduled at this time.

Feel free to write us if you have other questions.

All the best,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jim Moore
Top achievements
Rank 1
answered on 25 Jan 2008, 12:55 AM
What about embedding a label control in the cell to handle word wrapping?
0
Jack
Telerik team
answered on 25 Jan 2008, 01:34 PM
Hi Jim Moore,

Yes, this is a good suggestion. Indeed, it will affect the performance of RadGridView in general. You can insert a Label control in RadGridView's cell using the CellFormatting event.

Please refer to the following code snippet:

void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) 
    if (e.CellElement.ColumnInfo is GridViewTextBoxColumn && 
    ((GridViewTextBoxColumn)e.CellElement.ColumnInfo).DataField == "Name"
    { 
    if (e.CellElement.Children.Count == 0) 
    { 
        Label label = new Label(); 
        label.Text = e.CellElement.Value.ToString(); 
        label.ForeColor = Color.Black; 
        RadHostItem item = new RadHostItem(label); 
        e.CellElement.Children.Add(item); 
        e.CellElement.ForeColor = Color.Transparent; 
    } 
    else 
    { 
        Label label = (Label)((RadHostItem)e.CellElement.Children[0]).HostedControl; 
        label.ForeColor = Color.Black; 
        label.Text = e.CellElement.Value.ToString(); 
    } 
    } 

Please tell us if this solves the issue. We will be glad to help you further.

Best wishes,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jim Moore
Top achievements
Rank 1
answered on 12 Aug 2008, 10:09 PM
I've gotten distracted a bit - I notice that there is a new release of the RadGrid.

Does the new version solve the row auto height problem?

Thanks,

Jim
0
Jack
Telerik team
answered on 13 Aug 2008, 01:40 PM
Hi Jim Moore,

Thank you for this question.

We have implemented "auto row height" in RadGridView. Currently, this functionality is quite limited. We will try to fix all known issues in our upcoming service pack. You can try this feature by setting the AutoSizeRows property of RadGridView to true.

I hope this helps. Do not hesitate to write us if you have any other questions.

Sincerely yours,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Rick Hewitt
Top achievements
Rank 2
answered on 15 Sep 2008, 03:59 PM
I am on the current version of the winform controls and I have the following situation:

I have a column that is set to WrapText=true, I also have the AutoSizerows set to true but I still cannot seem to get the rows to auto size properly - something I am missing maybe?

Thanks,
Rick
0
Jack
Telerik team
answered on 16 Sep 2008, 09:53 AM
Hi Rick Hewitt,

Thank you for contacting us.

I confirm that currently there is a problem related to the RowAutoSize feature. We are aware of it and we plan to address it in our upcoming releases.

To work around the problem I suggest creating custom cells and overriding the MeasureOverride method. The code below demonstrates this behavior:

void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e) 
    if (e.CellType == typeof(GridDataCellElement) && e.Row is GridDataRowElement) 
    { 
        e.CellType = typeof(MyCell); 
    } 
 
public class MyCell : GridDataCellElement 
    public MyCell(GridViewColumn column, GridRowElement row) 
        : base(column, row) 
    { 
    } 
 
    protected override SizeF MeasureOverride(SizeF availableSize) 
    { 
        SizeF size = SizeF.Empty; 
        using (Graphics g = this.ElementTree.Control.CreateGraphics()) 
        { 
            size = g.MeasureString(this.Text, this.Font, 0, this.PaintTextFormat); 
        } 
        size.Width = this.ColumnInfo.GetActualWidth(); 
        size.Height += 30; 
        return size; 
    } 
 


I hope this helps. Do not hesitate to write me if you need further assistance.

 
Kind regards,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Andy
Top achievements
Rank 1
answered on 07 Oct 2008, 07:07 AM
Jack,

Your workaround does not work very well because the width passed to MeasureString is 0, so MeasureString always returns a height for one line.

I modified this workaround as follows: (Also note the easier to use static CreateCellHandler)

class FixedGridDataCellElement : GridDataCellElement {  
 
    public static void CreateCellHandler(object sender, GridViewCreateCellEventArgs e) {  
        if (e.CellType == typeof(GridDataCellElement) && e.Row is GridDataRowElement) {  
            e.CellType = typeof(FixedGridDataCellElement);  
        }  
    }  
 
    public FixedGridDataCellElement(GridViewColumn column, GridRowElement row)  
        : base(column, row) {  
    }  
 
    protected override SizeF MeasureOverride(SizeF availableSize) {  
 
        SizeF size = SizeF.Empty;  
        using (Graphics g = this.ElementTree.Control.CreateGraphics()) {  
            size = g.MeasureString(this.Text, this.Font, this.ColumnInfo.GetActualWidth(), this.PaintTextFormat);  
        }  
        size.Width = this.ColumnInfo.GetActualWidth();  
        return size;  
    }  
}  
 
0
Jack
Telerik team
answered on 08 Oct 2008, 07:42 AM
Hi Andy,

Thank you for your correction.

Indeed, your solution is better. I have missed to fill the Width parameter. Don't hesitate to write if you have any other suggestions.
 

All the best,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jiten
Top achievements
Rank 1
answered on 19 Jan 2009, 12:37 PM
Hi,

I am also using the latest Windows Rad Control.

I tried to make the the Auto Row Height by inheriting GridDataCellElement it is work fine. But still there is problem, when there is more data and then there is ScrollBar of RadGridView then at time of scrolling the height of all row become the same height, the largest height.

Please provide me better solutions.

Best Regards.
0
Jack
Telerik team
answered on 20 Jan 2009, 08:06 AM
Hello Jiten,

Thank you for contacting us.

We are aware of this issue. It will be addressed in our upcoming service pack which will be released later this week.

Should you have any other questions feel free to write us.

Kind regards,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jiten
Top achievements
Rank 1
answered on 20 Jan 2009, 12:10 PM
Hi,

Jack

Thanks for reply.

Hope i will get this solutions in upcoming service pack by later this week. I need this solutions asap.

Best Regards
0
Jack
Telerik team
answered on 21 Jan 2009, 01:33 PM
Hi Jiten,

Yes, the solution for this issue is included for Q3 2008 SP2 which is expected to be released any moment now. Please give it a go. We will highly appreciate any feedback.

Best wishes,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Geoff Calhoun
Top achievements
Rank 1
answered on 22 Jan 2009, 04:14 PM
I have downloaded Q3 2008 SP2 and tested the same but still facing same problem. Can you please send working example to make sure that I forgot to assign any of the properties or code?
0
Jack
Telerik team
answered on 22 Jan 2009, 06:01 PM
Hi Geoff,

I apologize for this inconvenience. Not all cases involving the AutoSizeRows property were resolved in this release. You should use custom row elements to work around the issue. Here is the code:

void radGridView1_CreateRow(object sender, GridViewCreateRowEventArgs e) 
    if (e.RowType == typeof(GridDataRowElement)) 
    { 
        e.RowElement = new MyRow(); 
    }             
 
public class MyRow: GridDataRowElement 
    protected override Type ThemeEffectiveType 
    { 
        get 
        { 
            return typeof(GridDataRowElement); 
        } 
    } 
    public override void Initialize(GridViewRowInfo rowInfo) 
    { 
        base.Initialize(rowInfo); 
        foreach (GridCellElement cell in this.Children) 
        { 
            cell.InvalidateMeasure(); 
        } 
        this.InvalidateMeasure(); 
    } 
 

The issue will be fully addressed in our next major release - Q1 2009. Of course, you should also set the AutoSizeRows to true.

In case you need further assistance, do not hesitate to contact us.

All the best,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Geoff Calhoun
Top achievements
Rank 1
answered on 27 Jan 2009, 06:32 PM
Thanks for update.

When we will have major release - Q1 2009? I want to make system live with AutoRowHeight functionality by mid of Feb. It will be released before that?
0
Jack
Telerik team
answered on 28 Jan 2009, 03:00 PM
Hello Geoff Calhoun,

We plan to release Q1 2009 by the end of February. Does the work around solve the AutoSizeRows issue?

Please write me back If you need further assistance

Sincerely yours,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Geoff Calhoun
Top achievements
Rank 1
answered on 28 Jan 2009, 04:12 PM
Yes. AutoRowsize issue has been resolved and working fine.
0
Fabien
Top achievements
Rank 2
answered on 03 Feb 2009, 08:55 AM
Hi,

this patch don't work for me. But anyway, I just have to set AutoSireRows to false.

I use last version, I create columns  and bind data myself. I use HtmlViewDefinition but rows are not well sized.

I have an other issue that i'll explain in an other post.

Best regards
0
Jack
Telerik team
answered on 03 Feb 2009, 03:02 PM
Hi Fabien,

In addition to setting the AutoSizeRows property to true you should also set the WrapText property of the desired column to true.

If this does not help, please provide us with more details about your case. This will allow us to assist you further.

I am looking forward to your reply.

Sincerely yours,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Arslan
Top achievements
Rank 1
answered on 26 Mar 2014, 10:52 AM
Sir  i am also suffering from this issue please help me out how i can do this ...Actually i am using a RadGridView to show the user Account log that can arrount 5 lines that is fetched from database but when i bind it to cell that have  widthof 600 but over flow not settled automatically.... 
0
George
Telerik team
answered on 31 Mar 2014, 09:53 AM
Hello Arslan,

Thank you for contacting us.

Can you please elaborate what problem are you experiencing exactly since I was not able to understand that from the currently provided information. If you want to AutoSize your rows and columns you will need to set the AutoSizeRows property of RadGridView and WrapText‚Äč to the column at hand:
this.Grid.Columns.Add("");
this.Grid.Rows.Add(new string('a', 600));
this.Grid.Columns.First().WrapText = true;
this.Grid.AutoSizeRows = true;

Keep in mind that you may experience the mentioned scroll behavior will occur. The behavior at hand is expressed in a changing scroll bar value which is due to the fact that a cell is measured when it becomes visible. We are aware of this behavior, however currently it cannot be changed.

Looking forward to your response.

Regards,
George
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Arslan
Top achievements
Rank 1
answered on 04 Apr 2014, 11:33 AM
Thanks George you replied my,
I have found same code form an other form and my issue resolved.as you wrote in your post ...Now i have an other issue with same grid and same column.Issue is that i want to add a command button in this cell that showing me Log Notes when user click on button a popup appears and show me detail.but  I am unaware that how i add this button ?
Like "Edit button"
0
George
Telerik team
answered on 09 Apr 2014, 10:40 AM
Hello Arslan,

Thank you for your reply.

You will need to create a custom cell as per this article. Also by reading through our TPF section you will get a better understanding of how our framework works and will allow you to create such custom scenarios. 

Let me know if you require further assistance.

Regards,
George
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
James
Top achievements
Rank 1
Answers by
Jack
Telerik team
Jim Moore
Top achievements
Rank 1
Rick Hewitt
Top achievements
Rank 2
Andy
Top achievements
Rank 1
Jiten
Top achievements
Rank 1
Geoff Calhoun
Top achievements
Rank 1
Fabien
Top achievements
Rank 2
Arslan
Top achievements
Rank 1
George
Telerik team
Share this question
or