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

columnwidth does not resizing to bestfit in width

2 Answers 10 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andre
Top achievements
Rank 1
Andre asked on 16 Apr 2018, 07:32 PM

hi

why does the column width not fit automatically when adding or deleting a row ?

when loading, it works.

 

 

       private void DgvTaskRunningLoad() {
            using (this.dgvTaskRunning.DeferRefresh()) {
                dgvTaskRunning.DataSource = Sql.Dashboard_listTaskRunning();

                // layout
                dgvTaskRunning.ShowGroupPanel = false;
                dgvTaskRunning.ReadOnly = true;
                dgvTaskRunning.ShowRowHeaderColumn = false;
                dgvTaskRunning.AutoScroll = true;
                dgvTaskRunning.MasterTemplate.AutoGenerateColumns = true;
                dgvTaskRunning.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None;
                dgvTaskRunning.BestFitColumns(BestFitColumnMode.AllCells);

                // grid
                dgvTaskRunning.Padding = new Padding(10);

                // cell
                dgvTaskRunning.TableElement.CellSpacing = 3;

                // column
                foreach (var col in dgvTaskRunning.Columns) {
                    col.IsVisible = false;
                }

                dgvTaskRunning.Columns[ColumnTitle.GridTasklistMail.subject].HeaderText = @"Task";
                dgvTaskRunning.Columns[ColumnTitle.GridOverviewTimestamp.dashboardUser].HeaderText = $@"User";
                dgvTaskRunning.Columns[ColumnTitle.GridTasklistMail.reference].HeaderText = $@"Reference";
                dgvTaskRunning.Columns[ColumnTitle.GridCostAccount.costAccount].HeaderText = $@"CostAccount";
                dgvTaskRunning.Columns[ColumnTitle.GridTaskTimestamp.timestampStart].HeaderText = $@"Start";
                dgvTaskRunning.Columns[ColumnTitle.GridOverviewTimestamp.hoursWorked].HeaderText = $@"hours worked";
                dgvTaskRunning.Columns[ColumnTitle.GridTasklistMail.description].HeaderText = $@"Description";

                dgvTaskRunning.Columns[ColumnTitle.GridTasklistMail.reference].TextAlignment = ContentAlignment.MiddleCenter;
                dgvTaskRunning.Columns[ColumnTitle.GridCostAccount.costAccount].TextAlignment = ContentAlignment.MiddleCenter;
                dgvTaskRunning.Columns[ColumnTitle.GridOverviewTimestamp.hoursWorked].TextAlignment = ContentAlignment.MiddleCenter;

                // visibility
                dgvTaskRunning.Columns[ColumnTitle.GridTasklistMail.subject].IsVisible = true;
                dgvTaskRunning.Columns[ColumnTitle.GridOverviewTimestamp.dashboardUser].IsVisible = true;
                dgvTaskRunning.Columns[ColumnTitle.GridTasklistMail.reference].IsVisible = true;
                dgvTaskRunning.Columns[ColumnTitle.GridCostAccount.costAccount].IsVisible = true;
                dgvTaskRunning.Columns[ColumnTitle.GridTaskTimestamp.timestampStart].IsVisible = true;
                dgvTaskRunning.Columns[ColumnTitle.GridOverviewTimestamp.hoursWorked].IsVisible = true;
                dgvTaskRunning.Columns[ColumnTitle.GridTasklistMail.description].IsVisible = true;

                // filtering
                dgvTaskRunning.EnableFiltering = true;
                dgvTaskRunning.ShowFilteringRow = false;
                dgvTaskRunning.ShowHeaderCellButtons = true;
            }
        }

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 17 Apr 2018, 10:08 AM
Hello Andre,

Thank you for writing.

By default, the BestFitColumns method is not automatically executed after any changes are made to the grid. You need to manually call the BestFitColumns method if you want to fit the columns again. 

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Andre
Top achievements
Rank 1
answered on 17 Apr 2018, 04:56 PM

hi dimitar

best thanks for the hint. bestfitcolumns only is not enough yet in my case but with the other parameters it works.
thank you !

Tags
GridView
Asked by
Andre
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Andre
Top achievements
Rank 1
Share this question
or