Hi,
I'm having some problems with the RadGridView's DataBindingComplete event handler in a async context and with the Telerik's WinForm RadGridView BestFitColumns method.
I'm developing an winforms with Telerik application that loads data from several db tables and shows them in distinct RadGridViews (one for each table source).
Each of the grids is inside a DocumentWindow. Each DocumentWindow is inside DocumentContainer and all of the DocumentContainers are under a single aggregating Docking.DocumentTabStrip.
The process db table information process is asyncronous so that the UI is free allowing the user to see the information in one table when it becomes available even if one of the other tables are still being loaded.
The first problem is that the DataBindingComplete is only triggered when the user selects the respective tab. Since some of the DataBindingComplete logic can be quite time consuming it leads to a undesired user experience until the data is finally presented.
Is there an alternative event that can be triggered when the data is already available in the RadGridView but without the need of having the user triggering it?
The second is with the way the BestFitColumns method determines the column width. The native DataGridView column's AutoSizeMode contains a option of AllDataCellsExceptHeader that I'm unable to emulate in Telerik.
The documentation for these options is rather scarce and all of the tried options fall short.
Of the available options the closest are the AllCells, DisplayedCells and DisplayedDataCells as the others do not take in account the cell's values.
The AllCells and DisplayedCells use the column headers as input and that makes data spread out too much, which is undesired.
The closest is DisplayedDataCells that sort of works but the logic seems to only use the cells in the rows in the visible range. (I.E.: the rows presented when the grid is presented in the UI). Trying to explain better, if form only displays the first Nth data rows, after the method runs the data will be visible correctly formatted, but if the (N+1) row data has a width larger than any of the first Nth rows the displayed data will be truncated and suffixed with the "..". Is there a way to emulate the AllDataCellsExceptHeader at all?
Thanks for your help.
Regards,
I've implement it using the following logic (snipped code).
(..)
private
async
void
displayButton_Click (
object
sender, EventArgs e) {
(..)
await Task.Run(() => Parallel.ForEach(tablesToRetrieve.Keys, tableID => {
(..)
DocumentWindow docWindow = ((DocumentWindow)returnedDataDocumentTabStrip.Controls[tableName]);
if
(GetDBTableData(tableID, tableArguments,
out
dataTable)) {
docWindow.Invoke((Action)
delegate
{
docWindow.Controls.Add(newRadView(dataTable));
docWindow.Refresh();
});
}
(..)
}));
}
(..)
private
RadGridView newRadView(DataTable dTable) {
RadGridView gridView =
new
RadGridView();
gridView.AutoSizeRows =
false
;
gridView.AllowAutoSizeColumns =
true
;
gridView.ReadOnly =
true
;
gridView.AutoExpandGroups =
true
;
gridView.AllowAddNewRow =
false
;
gridView.AllowDeleteRow =
false
;
gridView.AllowColumnReorder =
true
;
gridView.AllowColumnResize =
true
;
gridView.MultiSelect =
true
;
gridView.SelectionMode= GridViewSelectionMode.CellSelect;
gridView.EnableFiltering =
true
;
gridView.MasterTemplate.EnableFiltering =
true
;
gridView.ShowHeaderCellButtons =
true
;
gridView.EnableAlternatingRowColor =
true
;
gridView.EnableGrouping =
true
;
gridView.MasterTemplate.EnableGrouping =
true
;
gridView.EnableSorting =
true
;
gridView.MasterTemplate.EnableSorting =
true
;
gridView.TableElement.AlternatingRowColor = Color.FromArgb(240, 240, 240);
gridView.TableElement.RowHeight = 18;
gridView.ShowFilteringRow =
true
;
gridView.Dock = DockStyle.Fill;
gridView.AllowSearchRow =
true
;
gridView.SearchRowPosition = SystemRowPosition.Bottom;
gridView.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None;
gridView.Name = dTable.TableName;
/* Arm events handlers
gridView.ViewCellFormatting += gridView_ViewCellFormatting;
gridView.DataBindingComplete += gridView_DataBindingComplete;
gridView.ToolTipTextNeeded += gridView_ToolTipTextNeeded;
/* Load dataTable data */
gridView.BeginUpdate();
gridView.DataSource =
new
BindingSource(dataTable,
null
);
/* Customize table sort assumptions */
gridView.SortDescriptors.Add(
new
SortDescriptor(
"DUMMY_COLUMN"
, System.ComponentModel.ListSortDirection.Descending));
gridView.EndUpdate(
true
);
return
gridView;
}
(..)
private
void
gridView_ViewCellFormatting(
object
sender, CellFormattingEventArgs e) {
if
(e.CellElement.GetType() ==
typeof
(GridHeaderCellElement))
e.CellElement.TextWrap =
true
;
}
(..)
private
void
gridView_DataBindingComplete(
object
sender, GridViewBindingCompleteEventArgs e) {
RadGridView gridView = (RadGridView)sender;
/* Show/Shift/Hide columns to display */
(..)
/* Finally Adjust columns to it's data */
gridView.BestFitColumns(BestFitColumnMode.DisplayedDataCells);
}
Hi,
I was wondering how I would go about modifying the radCalender control so that the currentTimePointer is drawn only on the current week rather than on every week in the calendar.
I already have a customDayViewApppointmentsTable class that derives from the DayViewAppointmentsTable class that I've used to modify the size of the currentTimePointer, would the desired functionality be accessed through another override in this class?
Thanks,
Robert
I need a ComboBox column initialized with some data and the user can enter new data too when inserting new row into grid. For example, ComboBox column has three items by default Phone, Mobile, Fax, but the user needs to insert new item (e.g., Code). How can I do this?
Here is the code. With this code the user can only select one of the default values of combo column and he/she cannot enter his/her new value into combo column.
DataTable table =
new
DataTable();
table.Columns.Add(
"Name"
,
typeof
(
string
));
table.Columns.Add(
"Value"
,
typeof
(
string
));
var details = db.BatchItemDetails.Where(d => d.BatchItem_Id == _id)
.Select(d =>
new
{ d.Name, d.Value });
foreach
(var row
in
details)
table.Rows.Add(row.Name, row.Value);
grid.MasterTemplate.AutoGenerateColumns =
false
;
grid.DataSource = table;
GridViewComboBoxColumn name =
new
GridViewComboBoxColumn();
name.DataSource = (from b
in
db.Batches
join i
in
db.BatchItems on b.Id equals i.Batch_Id
join d
in
db.BatchItemDetails on i.Id equals d.BatchItem_Id
where b.Id == batchId
orderby d.Name
select d.Name).Distinct().ToArray();
// string array.
name.AutoCompleteMode = AutoCompleteMode.Suggest;
name.DropDownStyle = RadDropDownStyle.DropDown;
name.Name =
"Name"
;
name.FieldName =
"Name"
;
name.HeaderText =
"عنوان اطلاعات"
;
name.Width = 219;
name.TextAlignment = ContentAlignment.MiddleLeft;
grid.Columns.Add(name);
grid.Columns.Add(
"Value"
,
"Ø´Ø±Ø Ø§Ø·Ù„Ø§Ø¹Ø§Øª"
,
"Value"
);
grid.Columns[
"Value"
].Width = 353;
grid.AutoSizeRows =
true
;
Hello,
i created a custom cell element.
The custom part of the Element is a RadListControl.
The functionality works but I want the ListControl Element fit perfect in the Cell.
I have tried a lot and read many forum threads to find a solution but nothing works.
There are still Gaps (see Screenshot).
I hope someone can help me quick with my request.
Greets André
Hi,
I am using the scheduler and I need to change the connection string at run time. How can I do that?
Thanks for the help.
Hi, i would like to know if when a user close a page on the pageview, the controls inside this page will be dereferenced (thus become eligible for garbage collection) or if I have to handle the closed event and manually remove all the controls inside the page.
Also would like to know if there is something I can do to cleanup removed pages or if the removed pages are automatically managed by the pageview control or if i have to call dispose on the page itself in the closed event.
It's just to be sure not to lock too much memory for too long time, i did not find a documentation page about this.
Best regards
Andrea
if we are using simple combo box with let suppose database. below is the example of datasource
1. Florida = FL
2. NewYork = NY
3. New Jerssy = NJ
if user press N (combo box is selected) it will select New York and if user again press N it will select next item in the list New Jerssy. can we have same behavior with multicolumn combo box.
regards,
zeeshan
Dear,
is there any capability to change or set the column type dynamically to GridViewHyperlinkColumn after binding?
Regards,