Hi there,
I'm loading a RadGrid with AutoGenerateColumns="true", for databinding I'm using NeedDataSource(...) event handler. Since I want to format values from some columns I use the ColumnCreated(...) event handler. I also want to do some Aggregation based on the type of column. For this, I have the following helper method:
public static void ColumnCreated(object sender, Telerik.Web.UI.GridColumnCreatedEventArgs e)
{
if(!string.IsNullOrEmpty(e.Column.UniqueName))
{
GridBoundColumn gbc = e.Column as GridBoundColumn;
if (gbc != null)
{
gbc.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
gbc.HeaderText = gbc.UniqueName.ToUpper() == "EXPANDCOLUMN" ? string.Empty : gbc.UniqueName;
switch (gbc.DataTypeName.ToUpper())
{
case "SYSTEM.DATETIME":
gbc.DataFormatString = "{0:d}";
break;
case "SYSTEM.DECIMAL":
gbc.DataFormatString = "{0:N2}";
gbc.Aggregate = GridAggregateFunction.Sum;
gbc.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
gbc.FooterStyle.HorizontalAlign = HorizontalAlign.Right;
break;
}
}
}
}
But when this event fires something real "weird" is happening. I keep getting the following error:
Microsoft JScript runtime error:
Sys.WebForms.PageRequestManagerServerErrorException: cannot find column [xxxxxx].
When I mean "weird" is that such column does exist!.
On the other hand, when I comment out the logic inside ColumnCreated(...) event, the error does not show up. But as you might expect... the values are not formatted as well as there is no Aggregation on the columns that I want, and I do really want the event to fire since I need to do some formatting on the values of certain columns.
Thanks in advance,
Felix
Today, I tried a different approach. This time I used the ItemDataBound(...) event.
The code now is as follows:
protected void gvwOperaciones_ItemDataBound(object sender, GridItemEventArgs e)
{
if(e.Item.ItemType == GridItemType.AlternatingItem ||
e.Item.ItemType == GridItemType.Item)
{
int colIndex = 0;
DataRowView drv = e.Item.DataItem as DataRowView;
foreach (DataColumn dc in drv.DataView.Table.Columns)
{
GridDataItem gdi = e.Item as GridDataItem;
switch (dc.DataType.ToString().ToUpper())
{
case "SYSTEM.DATETIME":
gdi[dc.ColumnName].Text = string.Format("{0:d}", drv[dc.ColumnName]);
break;
case "SYSTEM.DECIMAL":
gdi[dc.ColumnName].Text = string.Format("{0:N2}", drv[dc.ColumnName]);
GridBoundColumn gbc = gvwOperaciones.MasterTableView.AutoGeneratedColumns[colIndex] as GridBoundColumn;
if(gbc != null)
gbc.Aggregate = GridAggregateFunction.Sum;
break;
default:
break;
}
colIndex++;
}
}
}
treeSrc.trackChanges();
treeDst.trackChanges();
treeSrc.get_nodes().remove(node);
treeDst.get_nodes().add(node);
treeSrc.commitChanges();
treeDst.commitChanges();
...
When I double click some tree node it will be actually moved. However, I also got a runtime error: "'null' is null or not an object"
...
if
(this.get_contextMenuIDs().length>0){
Telerik.Web.UI.RadContextMenu.hideAll();
}
},_expandOnHover:function(e){
if(Telerik.Web.UI.RadTreeView._draggingTreeView){
var _53=this._extractNodeFromDomElement(e.eventMapTarget);
this._hoveredNode=_53;
window.setTimeout(function(){
if(_53==_53._getControl()._hoveredNode){
_53.set_expanded(true);
}
},1000);
}
return true;
},_toggle:function(e){
var _55=this._extractNodeFromDomElement(e.eventMapTarget);
if(!_55.get_isEnabled()){ //This line causes problem
return;
}
this._hideContextMenus();
e.stopPropagation();
var _56=_55.get_expanded();
if(_56==false){
if(this.raise_nodeExpanding(_55)){
return;
}
...
any idea on this?
Cheers,
Elton