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

GridGroupHeaderItem button click event not called

0 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Asim
Top achievements
Rank 1
Asim asked on 03 Jul 2012, 06:39 AM
Dear Telerik Team

i have a very  basic problem, i have just added a  button on the group header in the pre-render event. following is the code.
when click the button this dont called the ItemCommand event for the grid. Please suggest the true way for calling the event.

protected void Item_PreRender(object sender, EventArgs e)
        {
            string text = ((GridGroupHeaderItem)sender).DataCell.Text;
 
            for (int i = 4; i < ((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns.Length; i++)
            {
                TableCell cell = new TableCell();
                if (((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns[i].UniqueName == "TESTDESC")
                {
                    cell.Text = text.Trim().Replace(": ", "");
                }
                if (((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns[i].UniqueName == "Name")
                {
                    cell.Text = "Name";
                }
                if (((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns[i].UniqueName == "ToTalScores")
                {
                    cell.Text = "Total Scores";
                }
                if (((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns[i].UniqueName == "REPORTINGTIME")
                {
                    cell.Text = "EST Time";
                }
                if (((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns[i].UniqueName == "MainGroupCollapse")
                {
                    Button ExpandControl = ((GridGroupHeaderItem)sender).Cells[0].Controls[0] as Button;
                    ExpandControl.CssClass = "rgCollapse";
                    cell.CssClass = "MainGroupCollapse";
                    cell.Controls.Add(ExpandControl);
                }
                if (((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns[i].UniqueName == "DOWNLOAD")
                {
                    LinkButton lnkDownloadBtn = new LinkButton();
                    lnkDownloadBtn.ID = "btnDownload";
                    lnkDownloadBtn.Text = "Download/Print";
                    lnkDownloadBtn.CommandName = "DownloadAndPrint";
                    lnkDownloadBtn.CssClass = "DownloadAndPrint";
                    cell.CssClass = "DownloadAndPrintCell";
                    cell.Controls.Add(lnkDownloadBtn);
                }
                if (((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns[i].UniqueName == "LeftSide")
                {
                    cell.CssClass = "LeftRightMargin";
                }
                ((GridGroupHeaderItem)sender).Cells.Add(cell);
            }
        }


protected void RadGridTest_ItemCommand(object source, GridCommandEventArgs e)
{
   GridGroupHeaderItem Item2 = e.Item as GridGroupHeaderItem;
   if (Item2 is GridGroupHeaderItem)
            {
                if (e.CommandName.Equals("DownloadAndPrint"))
                {
                     //call custom methods
                    //RenderReport(TestDateTreeView.SelectedNode.Value, "Chem");
                }
            }            
}


Many thanks
Asim Jabbar

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Asim
Top achievements
Rank 1
Share this question
or