Overriding column types

Discussion in 'ASP .Net Datagrid Control' started by Robert, Mar 7, 2004.

  1. Robert

    Robert Guest

    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;
    }
    }
    }
    }
    Robert, Mar 7, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sathyaish
    Replies:
    2
    Views:
    587
    Sathyaish
    May 22, 2005
  2. Soren Kuula
    Replies:
    2
    Views:
    561
    Henry S. Thompson
    Dec 1, 2005
  3. Jeremy Cowles

    STD types vs C++ intrinsic types

    Jeremy Cowles, Aug 18, 2003, in forum: C++
    Replies:
    5
    Views:
    1,883
    Bob Jacobs
    Aug 19, 2003
  4. Steve Knight
    Replies:
    2
    Views:
    754
    Steve Knight
    Oct 10, 2003
  5. Lonnie Princehouse

    Overriding builtin types

    Lonnie Princehouse, Mar 5, 2004, in forum: Python
    Replies:
    0
    Views:
    357
    Lonnie Princehouse
    Mar 5, 2004
Loading...

Share This Page