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

Fix columns to left

4 Answers 56 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 1
Anthony asked on 18 Dec 2013, 01:33 PM
Hello,
I have tried to customing a gridview row with html view like it is recommended in a few posts.
The result is not which i want, I want something like this:

[--colLeft--][----------------------col-----------------------]
[------------------------------------col-------------------------]
[--colLeft--][--colLeft--][--colLeft--][------col--------]

When I resize the gridviewI want to colLeft stay at left like:

[--colLeft--][----------------------------------------col------------------------------------]
[-----------------------------------------col---------------------------------------------------]
[--colLeft--][--colLeft--][--colLeft--][-----------------col----------------------------]


To make that I have used this C# code:

// Row struct in html view          
this.htmlView = new HtmlViewDefinition();
this.htmlView.RowTemplate.Rows.Add(new RowDefinition());
this.htmlView.RowTemplate.Rows.Add(new RowDefinition());
this.htmlView.RowTemplate.Rows.Add(new RowDefinition());
this.htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("IsLocked", 0, 1, 1));
this.htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("name", 0, 3, 1));
this.htmlView.RowTemplate.Rows[1].Cells.Add(new CellDefinition("details", 0, 4, 1));
this.htmlView.RowTemplate.Rows[2].Cells.Add(new CellDefinition("preview", 0, 1, 1));
this.htmlView.RowTemplate.Rows[2].Cells.Add(new CellDefinition("insert", 0, 1, 1));
this.htmlView.RowTemplate.Rows[2].Cells.Add(new CellDefinition("remove", 0, 1, 1));
this.htmlView.RowTemplate.Rows[2].Cells.Add(new CellDefinition("link", 0, 1, 1));

It works but when I'm resizing the gridview, cells are automaticly re-arranged (size and location) and centered so columns I want to fix on the left side (colLeft) moving. Like that:

[-------colLeft------][----------------------------------------col----------------------------------------------------]
[-----------------------------------------col----------------------------------------------------------------------------]
[-------colLeft------][-------colLeft------][------colLeft------][-----------------col----------------------------]


My question is How can I fix columns size to X pixels and location to left to make what I want?

Thanks



4 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 20 Dec 2013, 02:33 PM
Hi Anthony,

Thank you for writing.

Currently, RadGridView does not support fixed column widths when using a HTML view definition. I have logged this as a feature request in our Public Issue Tracking System - PITS. You can track its progress, subscribe for status change alerts and add your vote/comment on the following link - PITS Feature.

I have updated your Telerik Points for the suggestion.

Should you have further questions, I would be glad to help.

Regards,
Ivan Petrov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Anthony
Top achievements
Rank 1
answered on 29 Jan 2014, 08:01 AM
Hi Ivan,

I come back with a question in relation with my RadGridView. 
I want to customize a text into a cell (simply to make it bold).
My problem is that my cell wrap the text when it is too long (it work perfectly with a non customized text) but when I customize the text, it continue out of the cell (look pictures, one is with non customize text and the other with bold text).

I make it bold with html: 

gridViewTextBoxColumn2.DisableHTMLRendering = false;    
 
e.CellElement.Text = "<html><b>" + myText + "</b></html>";

My question is how to fix this issue ? 

Thank you


0
Ivan Petrov
Telerik team
answered on 29 Jan 2014, 06:11 PM
Hello Anthony,

Thank you for writing back.

Due to the implementation of the HTML-like text formatting it cannot be clipped by elements. In your case a more suitable approach would be to use the CellFormatting event of RadGridView. Since you will be changing fonts we always advise our clients to create a font as a field or a singleton property and use this font for the formatting purposes. This is advisable as creation of Font objects is a heavy operation which can easily lead to memory leaks and performance degradation. Here is an example:
private Font boldFont = new Font(new FontFamily("Calibri"), 12.0F, FontStyle.Bold);
 
private void grid_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (someCondition)
    {
        e.CellElement.Font = boldFont;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.FontProperty, Telerik.WinControls.ValueResetFlags.Local);
    }
}

I hope this will be useful. Feel free to write back with further questions.

Regards,
Ivan Petrov
Telerik
TRY TELERIK'S NEWEST PRODUCT - APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Anthony
Top achievements
Rank 1
answered on 30 Jan 2014, 08:26 AM
Thank you so much Ivan. You are the best !
Tags
GridView
Asked by
Anthony
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Anthony
Top achievements
Rank 1
Share this question
or