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

Radgrid Column width problems, please help!!!

1 Answer 378 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ghostho
Top achievements
Rank 1
ghostho asked on 03 Sep 2019, 08:31 AM

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;

 

1 Answer, 1 is accepted

Sort by
0
Eric R | Senior Technical Support Engineer
Telerik team
answered on 05 Sep 2019, 09:52 PM

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.
Tags
Grid
Asked by
ghostho
Top achievements
Rank 1
Answers by
Eric R | Senior Technical Support Engineer
Telerik team
Share this question
or