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

HeaderContextFilterMenu in RadGrid

4 Answers 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jiju
Top achievements
Rank 1
Jiju asked on 14 May 2012, 01:09 PM
Hello

I have a radgrid of Telerik 2012. The columns are created dynamically as GridBoundColumns. I have set the property EnableHeaderContextFilterMenu to true. My requirement is that, how to put a header context filter menu to the dynamically created gridboundcolumn.

Any help will be highly appreciated.

Regards
Jiju.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 May 2012, 01:25 PM
Hi Jiju,

Please take a look into the following code snippet to set the EnableHeaderContextFilterMenu to true dynamically.

C#:
protected void Page_Init(object sender, EventArgs e)
{
   . . .
   RadGrid1.EnableHeaderContextFilterMenu = true;
   RadGrid1.EnableHeaderContextMenu = true;
   RadGrid1.AllowFilteringByColumn = true;
   RadGrid1.AllowSorting = true;
  . . .
}

Regards,
Shinu.
0
Jiju
Top achievements
Rank 1
answered on 14 May 2012, 01:34 PM
Hello Shinu

First of all thanks for your help.

The mentioned properties are already set to true. From the demos I could find that header context filter menu is implemented using gridtemplatecolumn, header template and image button, that also at client side. My requirement is how to set like this for a gridboundcolumn at server side.

Regards
Jiju.
0
Accepted
Shinu
Top achievements
Rank 2
answered on 15 May 2012, 06:13 AM
Hi Jiju,

I guess you want an image attached with the GridBoundColumn and want to show EnableHeaderContextFilterMenu on click of that image.Here is the sample code snippet I tried to show the same dynamically.

C#:
void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridHeaderItem)
    {
        GridHeaderItem item = (GridHeaderItem)e.Item;
        TableCell cell = (TableCell)item["EmployeeID"];
        Image img = new Image();
        img.ImageUrl="~/Images/img1.jpg";
        img.ID = "img1";
        img.Attributes.Add("onclick", "ShowColumnHeaderMenu(event,'EmployeeID')"); // EmployeeID is the UniqueName of the BoundColumn
        cell.Controls.Add(img);
    }
}

Javascript:
<script type="text/javascript">
    function ShowColumnHeaderMenu(ev, columnName)
    {
        var grid = $find("<%=RadGrid1.ClientID %>");
        var columns = grid.get_masterTableView().get_columns();
 
        for (var i = 0; i < columns.length; i++) {
            if (columns[i].get_uniqueName() == columnName) {
                columns[i].showHeaderMenu(ev, 75, 20);
            }
        }
    }
</script>

Thanks,
Shinu.
0
Jiju
Top achievements
Rank 1
answered on 15 May 2012, 01:24 PM
Hello Shinu

Great..It really solved my problem. Thanks a lot....


Regards
Jiju.
Tags
Grid
Asked by
Jiju
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jiju
Top achievements
Rank 1
Share this question
or