Overriding column types

R

Robert

I have created a custom, scrollable datagrid with expandable
(draggable) columns. However, I accomplished the expandable column
part in a very bad way by basically intercepting the output from the
rendering and doing a search/replace on the td tag to add attributes.
It all works perfect for BoundColumns, but can misbehave with Template
and Button columns.

It seems what I want really want to do is create a class for each
column type and override the implementation to add particular
information for each column. But I'm not sure how to do that.

I thought it would be as simple as creating a class named BoundColumn
that inherits from DataGridColumn, add my info to the cell and so on
for the other types. That doesn't seem to be working.

Does anyone have any experience with this?

namespace MyScrollGrid
{
/// <summary>
/// Summary description for BoundColumn.
/// </summary>
public class BoundColumn : DataGridColumn
{
public BoundColumn() : base()
{
//
// TODO: Add constructor logic here
//
}

public string DataField
{
get{return this.DataField;}
set{this.DataField = value;}
}

public override void InitializeCell(TableCell cell, int columnIndex,
ListItemType itemType)
{

base.InitializeCell(cell, columnIndex, itemType);

switch(itemType)
{
case ListItemType.Item:
case ListItemType.AlternatingItem:
case ListItemType.SelectedItem:
{
cell.Attributes.Add("style","'text-overflow: ellipsis; overflow:
hidden;");
cell.Width=Unit.Pixel(140);
break;
}
case ListItemType.EditItem:
break;
}
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top