We are passing a DataTable to our radGrid via the code behind. When the grid initally loads the data displays correctly. As soon as we filter, it ignores the Filter Expression and filters all the data not by the initial Hierarchy.
rgCategories.EnableLinqExpressions = false; |
rgCategories.MasterTableView.FilterExpression = @"([ParentCategoryId] = 0)"; |
Here is our SQL code
SELECT DISTINCT [MEPDB].[MEPBUS].[CATEGORY].[category_id] AS [CategoryId], [MEPDB].[MEPBUS].[CATEGORY].[parent_category_id] AS [ParentCategoryId], [MEPDB].[MEPBUS].[CATEGORY].[level] AS [Level], [MEPDB].[MEPBUS].[CATEGORY].[name] AS [Name], [MEPDB].[MEPBUS].[CATEGORY].[description] AS [Description], [MEPDB].[MEPBUS].[CATEGORY].[home_message] AS [HomeMessage], [MEPDB].[MEPBUS].[CATEGORY].[email_address] AS [EmailAddress], [MEPDB].[MEPBUS].[CATEGORY].[create_date] AS [CreateDate], [MEPDB].[MEPBUS].[CATEGORY].[update_date] AS [UpdateDate], [MEPDB].[MEPBUS].[CATEGORY].[create_by] AS [CreateBy], [MEPDB].[MEPBUS].[CATEGORY].[update_by] AS [UpdateBy], [MEPDB].[MEPBUS].[CATEGORY].[is_submission_allowed] AS [IsSubmissionAllowed], [MEPDB].[MEPBUS].[CATEGORY].[is_enabled] AS [IsEnabled], [MEPDB].[MEPBUS].[CATEGORY].[is_render_home_page] AS [IsRenderHomePage], [MEPDB].[MEPBUS].[CATEGORY].[is_protected] AS [IsProtected] FROM [MEPDB].[MEPBUS].[CATEGORY] WHERE ( ( ( [MEPDB].[MEPBUS].[CATEGORY].[parent_category_id] IS NOT NULL))) ORDER BY [MEPDB].[MEPBUS].[CATEGORY].[parent_category_id] ASC,[MEPDB].[MEPBUS].[CATEGORY].[name] ASC |
Markup Code
<telerik:RadGrid |
ID="rgCategories" |
runat="server" |
AllowPaging="True" |
AutoGenerateColumns="false" |
AllowSorting="True" |
CommandItemDisplay="Top" |
GridLines="None" |
PageSize="20" |
AllowFilteringByColumn="true" |
GroupingSettings-CaseSensitive="false" |
OnNeedDataSource="rgCategories_NeedDataSource" |
OnPreRender="rgCategories_PreRender" |
OnItemCommand="rgCategories_ItemCommand" |
> |
<MasterTableView DataKeyNames="CategoryId,ParentCategoryId" HierarchyLoadMode="Client" Width="100%"> |
<Columns> |
<telerik:GridBoundColumn |
DataField="CategoryID" |
HeaderText="<%$Resources:meis,Labels_ID%>" |
SortExpression="CategoryID" |
/> |
<telerik:GridHyperLinkColumn |
DataNavigateUrlFields="CategoryID" |
HeaderText="<%$Resources:meis,Labels_Name%>" |
DataNavigateUrlFormatString="CategoryEdit.aspx?CategoryID={0}" |
DataType="System.String" |
DataTextField="Name" |
DataTextFormatString="{0}" |
SortExpression="Name" |
/> |
<telerik:GridBoundColumn |
DataField="Description" |
HeaderText="<%$Resources:meis,Labels_Description%>" |
SortExpression="Description" |
/> |
<telerik:GridHyperLinkColumn |
HeaderText="<%$Resources:meis,Labels_AddSubCategory %>" |
AllowFiltering="false" |
DataNavigateUrlFields="CategoryID" |
DataNavigateUrlFormatString="CategoryEdit.aspx?ParentCategoryID={0}" |
Text="<%$Resources:meis,Labels_AddSubCategory %>" |
/> |
</Columns> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
<SelfHierarchySettings |
ParentKeyName="ParentCategoryId" |
KeyName="CategoryId" |
/> |
</MasterTableView> |
</telerik:RadGrid> |