Fix columns to left

5 posts, 0 answers
  1. Anthony
    Anthony avatar
    3 posts
    Member since:
    Dec 2013

    Posted 18 Dec 2013 Link to this post

    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



  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    707 posts

    Posted 20 Dec 2013 Link to this post

    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 >>
  3. Anthony
    Anthony avatar
    3 posts
    Member since:
    Dec 2013

    Posted 29 Jan 2014 Link to this post

    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


  4. Ivan Petrov
    Admin
    Ivan Petrov avatar
    707 posts

    Posted 29 Jan 2014 Link to this post

    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 >>
  5. Anthony
    Anthony avatar
    3 posts
    Member since:
    Dec 2013

    Posted 30 Jan 2014 in reply to Ivan Petrov Link to this post

    Thank you so much Ivan. You are the best !
Back to Top