GridDragDropColumn cannot be dragged when added to a dynamically created Grid. The issue can be reproduced with the following code:
override protected void OnInit(EventArgs e)
{
RadGrid gr = new RadGrid();
gr.ID = "testGrid";
gr.AutoGenerateColumns = false;
gr.NeedDataSource += gr_NeedDataSource;
GridDragDropColumn columnDrag = new Telerik.Web.UI.GridDragDropColumn();
columnDrag.HeaderStyle.Width = Unit.Pixel(40);
columnDrag.HeaderText = "Drag";
fileExplorer.Grid.Columns.Add(columnDrag);
//gr.MasterTableView.Columns.Add(columnDrag);
gr.ClientSettings.AllowRowsDragDrop = true;
gr.ClientSettings.Selecting.AllowRowSelect = true;
Page.Controls.Add(gr);
}
The PageInit method is defined as:
protected internal override void OnInit(EventArgs e)
{
base.OnInit(e); // this will call the On_Init event if there is such attached
if (this._theme != null)
{
this._theme.SetStyleSheet();
}
if (this._styleSheet != null)
{
this._styleSheet.SetStyleSheet();
}
}
This means that if you override OnInit, you should at least call the base OnInit at the end of your code, not at the beginning.
override protected void OnInit(EventArgs e) {
... code ...
base.OnInit(e);
}
There is no difference using override OnInit vs. hooking an event handler on the page..
override protected void OnInit(EventArgs e) {
base.OnInit(e);
... code ...
}
The request was: How to add a GridDragDropColumn to the RadFileExplorer contol.. All is fine on grid only pages..
I ended up doing this:
if (Telerik.Web.UI.FileExplorer && Telerik.Web.UI.FileExplorer.GridFileList) {
Telerik.Web.UI.FileExplorer.GridFileList.prototype.org_onRowDataBound = Telerik.Web.UI.FileExplorer.GridFileList.prototype._onRowDataBound;
Telerik.Web.UI.FileExplorer.GridFileList.prototype._onRowDataBound = function (grid, args) {
this.org_onRowDataBound(grid, args);
var tr = args.get_item("Name").get_element();
var cellElement = tr.cells[0];
cellElement.innerHTML = '<a id="dummy_DragDropColumnRowDragHandle" class="rgActionButton rgDragIcon rgIcon"></a>';
}
}
Deleted: Improper way of adding the controls. The Init should not be overridden. But instead the Page_Init handler should be used