Hi,
I had enabled HeaderContextFilterMenu in a radgrid and added edittemplate for one of the editable column. However, the filter is not working with this column though it works in case of default radfilter (without HeaderContextFilterMenu)
Attached is the RadGridFilter sanpshot for your reference.
Regards,
Preeti
I had enabled HeaderContextFilterMenu in a radgrid and added edittemplate for one of the editable column. However, the filter is not working with this column though it works in case of default radfilter (without HeaderContextFilterMenu)
Attached is the RadGridFilter sanpshot for your reference.
Regards,
Preeti
4 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 23 May 2013, 05:47 AM
Hi Preeti,
I have done an example using ContextFilter. Please check this and see if it helps you,
else,provide your code so that i may see what went wrong.
ASPX:
JAVASCRIPT:
Thanks,
Princy
I have done an example using ContextFilter. Please check this and see if it helps you,
else,provide your code so that i may see what went wrong.
ASPX:
<telerik:RadGrid AutoGenerateColumns="false" ID="RadGrid1" DataSourceID="SqlDataSource1" AllowFilteringByColumn="True" AllowSorting="True" PageSize="15" ShowFooter="True" AllowPaging="True" runat="server" EnableLinqExpressions="false" EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true" AutoGenerateEditColumn="true"> <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle> <GroupingSettings CaseSensitive="false"></GroupingSettings> <MasterTableView AutoGenerateColumns="false" EditMode="InPlace" ShowFooter="True" TableLayout="Auto"> <Columns> <telerik:GridNumericColumn DataField="OrderID" HeaderText="OrderID" SortExpression="OrderID" UniqueName="OrderID"> </telerik:GridNumericColumn> <telerik:GridBoundColumn DataField="ShipName" HeaderText="ShipName" SortExpression="ShipName" UniqueName="ShipName"> </telerik:GridBoundColumn> <telerik:GridDateTimeColumn DataField="OrderDate" HeaderText="OrderDate" SortExpression="OrderDate" UniqueName="OrderDate" PickerType="None" DataFormatString="{0:d}"> </telerik:GridDateTimeColumn> <telerik:GridDateTimeColumn DataField="ShippedDate" HeaderText="ShippedDate" SortExpression="ShippedDate" UniqueName="ShippedDate" PickerType="DatePicker" DataFormatString="{0:D}"> <HeaderStyle Width="160px"></HeaderStyle> </telerik:GridDateTimeColumn> <telerik:GridBoundColumn DataField="ShipCountry" HeaderText="ShipCountry" SortExpression="ShipCountry" UniqueName="ShipCountry"> </telerik:GridBoundColumn> <telerik:GridTemplateColumn DataField="ShipCity" GroupByExpression="ShipCity Group by ShipCity" UniqueName="ShipCity" InitializeTemplatesFirst="false" HeaderStyle-Width="100" HeaderText="Ship city"> <HeaderTemplate> <table> <tr> <td> <asp:LinkButton ID="lnkSort" runat="server" CommandArgument="ShipCity" CommandName="Sort" Text="Ship city"></asp:LinkButton> </td> <td> <img src="down.jpg" style="margin-top: 5px; margin-left: 5px; cursor: pointer" onclick='ShowColumnHeaderMenu(event,"ShipCity")' alt="Show context menu" /> </td> </tr> </table> </HeaderTemplate> <ItemTemplate> <asp:Label ID="lblCity" runat="server" Text='<%#Eval("ShipCity") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:Label ID="lblCity5" runat="server" Text='<%#Eval("ShipCity") %>'></asp:Label> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridMaskedColumn DataField="ShipPostalCode" HeaderText="ShipPostalCode" SortExpression="ShipPostalCode" UniqueName="ShipPostalCode" Mask="#####"> <FooterStyle Font-Bold="true"></FooterStyle> </telerik:GridMaskedColumn> <telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal" HeaderText="Freight" SortExpression="Freight" UniqueName="Freight" Aggregate="Sum"> <FooterStyle Font-Bold="true"></FooterStyle> </telerik:GridNumericColumn> </Columns> </MasterTableView> <ClientSettings> <Scrolling AllowScroll="false"></Scrolling> </ClientSettings> </telerik:RadGrid>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,
Princy
0
Preeti
Top achievements
Rank 1
answered on 23 May 2013, 02:36 PM
Hi Princy,
I tried the solution provided by you. However, it is still not working for me. Below is the code snippet for your reference. Can you please check and let me know what more can be done.
<telerik:radgrid id="radGrd" allowmultirowedit="false" cellpadding="0" cellspacing="0"runat="server" allowsorting="true" allowfilteringbycolumn="true" allowpaging="true"onneeddatasource="radGrd_NeedDataSource" onitemcommand="radGrd_ItemCommand" onitemcreated="radGrd_ItemCreated"onupdatecommand="radGrd_UpdateCommand" ondeletecommand="radGrd_DeleteCommand"enableheadercontextmenu="true" groupingenabled="false" enableheadercontextfiltermenu="true"enablelinqexpressions="false" onitemdatabound="radGrd_ItemDataBound"> <MasterTableView AutoGenerateColumns="False" EditMode="InPlace" CommandItemDisplay="Bottom"PageSize="10" TableLayout="Fixed" CommandItemSettings-ShowAddNewRecordButton="false"CommandItemSettings-ShowRefreshButton="false" HeaderStyle-HorizontalAlign="Center"HeaderStyle-Font-Bold="true" AllowFilteringByColumn="True" EnableHeaderContextMenu="true"IsFilterItemExpanded="false"> <NoRecordsTemplate> No records available</NoRecordsTemplate> <PagerStyle HorizontalAlign="Right" Position="TopAndBottom" VerticalAlign="Middle"Mode="NextPrevAndNumeric" AlwaysVisible="true" PageButtonCount="5"></PagerStyle> <Columns> <telerik:GridTemplateColumn HeaderText="Value" DataField="AttVal"UniqueName="AttVal" ItemStyle-Width="40px" AutoPostBackOnFilter="true"HeaderStyle-Width="100px" ItemStyle-HorizontalAlign="Left" DataType="System.String"> <ItemTemplate> <asp:Label ID="lblAttVal" runat="server" Text='<%# Bind("AttVal") %>' Width="10px"></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtAttributeValue" runat="server" Text='<%# Bind("AttVal") %>' Width="82px"></asp:TextBox> <asp:RequiredFieldValidator ID="rfvAttVal" runat="server" ControlToValidate="txtAttVal"Enabled="true" ErrorMessage="<br />Enter Value" Font-Size="Small" ForeColor="Brown" Display="Dynamic"></asp:RequiredFieldValidator> <asp:CustomValidator ID="cvAttVal" runat="server" EnableClientScript="true"ErrorMessage="Enter Valid Value" OnServerValidate="CustomValidateAttribute_ServerValidate"ControlToValidate="txtAttVal" Display="Dynamic" ForeColor="Red"> </asp:CustomValidator> </EditItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView> <ClientSettings> <Scrolling AllowScroll="True" ScrollHeight="300px" UseStaticHeaders="true"></Scrolling> </ClientSettings> </telerik:radgrid> Thanks,
Preeti
0
Princy
Top achievements
Rank 2
answered on 24 May 2013, 04:19 AM
Hi Preeti,
I have checked your code and its working fine in my system.
Here is a Demo of CONTEXTFILTERMENU ,please have a look at this.
Thanks
Princy
I have checked your code and its working fine in my system.
Here is a Demo of CONTEXTFILTERMENU ,please have a look at this.
Thanks
Princy
0
Preeti
Top achievements
Rank 1
answered on 24 May 2013, 01:47 PM
Hi Princy,
For me the issue still persists. Just for your information, I am binding a list to the radgrid. And the column which is having filter issue is of Object type. Is there anyway to update the datatype from object to string while binding to radgrid or anyother alternative to handle this column?
Thanks,
Preeti
For me the issue still persists. Just for your information, I am binding a list to the radgrid. And the column which is having filter issue is of Object type. Is there anyway to update the datatype from object to string while binding to radgrid or anyother alternative to handle this column?
Thanks,
Preeti