Radgrid Column width problems, please help!!!

2 posts, 0 answers
  1. ghostho
    ghostho avatar
    1 posts
    Member since:
    Jan 2016

    Posted 03 Sep Link to this post

    Hello,

    i want to use RadGrid in asp.net with dynamical columns with different widths. There is no autosizing like autofit. I tried it with javascript. It works but it isnt a good solution. I tried here with some functions, but nothing happens on sizing. Only text will be changed. Visible unvisible is also not working. I think telerik is in grid a very bad solution.

     

    in page:

     

     <telerik:RadGrid ID="rgrdSuche" runat="server" Culture="de-DE" OnColumnCreated="rgrdSuche_ColumnCreated" OnSortCommand="rgrdSuche_SortCommand">
                    <MasterTableView AutoGenerateColumns="true" AllowFilteringByColumn="false">
                   
                    </MasterTableView>               
                </telerik:RadGrid>

     

     

    i tried with the event itemdatabound, but nothing happened:

     

     protected void rgrdSuche_ItemDataBound(object sender, GridItemEventArgs e)
            {
                try
                {
                    if (e.Item is GridHeaderItem)
                    {
                        GridHeaderItem headerItem = e.Item as GridHeaderItem;

                        for (int i = 0; i < headerItem.Cells.Count; i++)
                        {
                            switch (headerItem.Cells[i].Text.Replace(" ", ""))
                            {
                                case "Comment":
                                    headerItem.Cells[i].Text = "Comment-Text";
                                    headerItem.Cells[i].Width = Unit.Pixel(400);
                                    break;
                                default:
                                    break;
                   ...

     

    and event via ColumnCreated will not work also:

     

      protected void rgrdSuche_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
            {
                switch (e.Column.UniqueName)
                {
                    case "Comment":
                        e.Column.Visible = false;
                        e.Column.HeaderText = "Comment-Text";
                        e.Column.HeaderStyle.Width = Unit.Pixel(400);
                        e.Column.FilterControlWidth = Unit.Pixel(400);
                     break;

     

  2. Eric R | Technical Support Engineer
    Admin
    Eric R | Technical Support Engineer avatar
    230 posts

    Posted 05 Sep Link to this post

    Hi Ghostho,

    RadGrid columns have many Resizing Features. I recommend using the Column/Row Resizing demo and adjusting the configurations to find the desired style. In this case, I believe setting the Allow Column Reszing, Enable Real-Time Resizing, No Wrap for Cell Content and Allow Resize to Fit properties will meet the desired style.

    For additional information, see the Column Resizing documentation.

    I hope this helps. Please let me know if you have any additional questions. Thank you for using the UI for ASP.NET AJAX Forums.

    Regards,


    Eric R | Technical Support Engineer
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top