This is a migrated thread and some comments may be shown as answers.

Header Context Menu on Header left click

2 Answers 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Niraj
Top achievements
Rank 1
Niraj asked on 10 Jan 2011, 08:39 AM
Hi,

 Can I associate GridHyperLink or GridDateTime Column in the GridTemplate column?
I just want to change the header template, I dont want to change the item template. Is this possible..?
I am embedding a image button inside the header for each column. Can I have the header context menu on click event of this image button.?
If so, what is the CommandName for header context menu and CommandArgument for the same. ?


Regards,
Niraj Khose

2 Answers, 1 is accepted

Sort by
0
Niraj
Top achievements
Rank 1
answered on 11 Jan 2011, 07:01 AM

 

 

)

 

 

Hi,

 

I have used this code(in ItemDataBound Event) which was posted on one your forums.I also tried it on ItemCreatedEvent. But the problem is(in both cases) it is only putting the image button for only the first column . Can you explain this?
//if (e.Item is GridHeaderItem)
//{

 

 

 

// ImageButton button = new ImageButton();

 

 

 

// button.ID = "ContextButton" + i.ToString();

 

 

 

// i++;

 

 

 

// button.AlternateText = "ContextButton";

 

 

 

// button.ImageUrl = "1294371072_email.png";

 

 

 

// button.OnClientClick = "showMenu(this, event); return false;";

 

 

 

// e.Item.Cells[2].Controls.Add(button);

 

 

 

//}

Regards,
Niraj Khose.

 

 

0
Princy
Top achievements
Rank 2
answered on 11 Jan 2011, 09:57 AM
Hello Niraj,

You need to loops through each column to add ImageButton for all the columns in RadGrid.

C#:
int i = 1;
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridHeaderItem)
    {
        foreach (GridColumn col in RadGrid1.Columns)
        {
            GridHeaderItem headerItem = (GridHeaderItem)e.Item;
            ImageButton button = new ImageButton();
            button.ID = "ContextButton" + i.ToString();
            i++;
            button.AlternateText = "ContextButton";
            button.ImageUrl = "1294371072_email.png";
            button.OnClientClick = "showMenu(this, event); return false;";
            e.Item.Cells[i].Controls.Add(button);
        }
    }
}

Thanks,
Princy.
Tags
Grid
Asked by
Niraj
Top achievements
Rank 1
Answers by
Niraj
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or