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

Filter dataGrid

3 Answers 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
william
Top achievements
Rank 1
william asked on 16 Nov 2010, 01:20 AM
Hello,

I'm triying to implement a filter control besides a rad grid control. However i have had some problems with its visualization. I have followed the recommendations about the controls nevertheless the filter control doesn't display. I have reviewed the filter code and the datasource as well.
Any Suggestion??
<telerik:RadAjaxManager id="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="grid" >
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="grid" LoadingPanelID="RadAjaxLoadingPanel1" />
                <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
 
 <telerik:RadGrid  runat="server" ID="grid" AutoGenerateColumns="False"
    AllowPaging="True" OnNeedDataSource="grid_NeedDataSource" OnUpdateCommand="RadGrid1_UpdateCommand"
    OnInsertCommand="RadGrid1_InsertCommand"  OnItemCommand="RadGrid1_ItemCommand"
    onpageindexchanged="grid_PageIndexChanged"  OnItemDataBound="RadGrid1_ItemDataBound" FilterItemStyle-Wrap="true"
                    Culture="es-CO" GridLines="None"   >
    <MasterTableView DataKeyNames="" CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage" EditMode="EditForms">
        <Columns>   
     <telerik:GridBoundColumn UniqueName="id" DataField="id" HeaderText="Id" 
            ForceExtractValue="InEditMode" ConvertEmptyStringToNull="true" Visible="false" >
      </telerik:GridBoundColumn>
      <telerik:GridTemplateColumn  UniqueName="Sociedad" DataField="Sociedad" HeaderText="Sociedad"
             ForceExtractValue="InEditMode" ConvertEmptyStringToNull="true"  >              
              <EditItemTemplate>   
                        <asp:DropDownList CssClass="dropdownlist" ID="ddlContainerSociedad" runat="server"></asp:DropDownList
                         <asp:Label ID="LabelCompanyID" runat="server" Text='<%#Eval("CompanyID") %>'></asp:Label>                   
                    </EditItemTemplate>
                        <ItemTemplate>
                        <asp:Label ID="LabelCompanyID" runat="server" Text='<%#Eval("CompanyID") %>'></asp:Label>
                    </ItemTemplate>
                     <FilterTemplate>
                <telerik:RadComboBox ID="cbFSociedad" runat="server" DataSourceID="SqlDataSource1"
                    DataTextField="CompanyID" DataValueField="CompanyID" AppendDataBoundItems="true"
                    SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("Sociedad").CurrentFilterValue %>'
                    OnClientSelectedIndexChanged="TitleIndexChanged" >
                    <Items>
                        <telerik:RadComboBoxItem Text="Todas" />
                    </Items>
                </telerik:RadComboBox>
                <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                    <script type="text/javascript">
                        function TitleIndexChanged(sender, args) {
                            var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                            tableView.filter("Sociedad", args.get_item().get_value(), "Contains");
                        }
                    </script>
                </telerik:RadScriptBlock>
            </FilterTemplate>
                               
             </telerik:GridTemplateColumn>
 
       <telerik:GridEditCommandColumn ButtonType="ImageButton" />          
        </Columns>   
    </MasterTableView>
    <PagerStyle Mode="NextPrevAndNumeric" />
</telerik:RadGrid>
 <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:PanalpinaEntities %>" 
            SelectCommand="SELECT distinct
      [CompanyID]     
  FROM [Panalpina].[dbo].[SAPCenterCostBranch]
order by [CompanyID]      " ProviderName="System.Data.SqlClient">
        </asp:SqlDataSource>


Best Wishes,
William

3 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 17 Nov 2010, 04:58 PM
Hi William,

Could you please try setting the RadGrid.AllowFilteringByColumn property to true:
<telerik:RadGrid AllowFilteringByColumn="true" runat="server" ID="grid" AutoGenerateColumns="False" AllowPaging="True" OnNeedDataSource="grid_NeedDataSource" OnUpdateCommand="RadGrid1_UpdateCommand" OnInsertCommand="RadGrid1_InsertCommand" OnItemCommand="RadGrid1_ItemCommand" OnPageIndexChanged="grid_PageIndexChanged" OnItemDataBound="RadGrid1_ItemDataBound" FilterItemStyle-Wrap="true" Culture="es-CO" GridLines="None">

I hope this helps.

Sincerely yours,
Radoslav
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
william
Top achievements
Rank 1
answered on 18 Nov 2010, 09:51 PM
Hi Radoslav,

Sorry unfortunately it doesn't work. when I add  'AllowFilteringByColumn="true"' the application throws the following exception:

Keyword not supported: 'metadata'. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
Exception Details: System.ArgumentException: Keyword not supported: 'metadata'.

Any suggestion??
Best Wishes,
William

0
william
Top achievements
Rank 1
answered on 19 Nov 2010, 11:37 PM
I have fixed this issue, finally my code looks like this:

<telerik:RadGrid  runat="server" ID="grid" AutoGenerateColumns="False"
    AllowPaging="True" OnNeedDataSource="grid_NeedDataSource" OnUpdateCommand="RadGrid1_UpdateCommand"
    OnInsertCommand="RadGrid1_InsertCommand"  OnItemCommand="RadGrid1_ItemCommand"
    onpageindexchanged="grid_PageIndexChanged"  OnItemDataBound="RadGrid1_ItemDataBound" FilterItemStyle-Wrap="true"
                    Culture="es-CO" GridLines="None"   AllowFilteringByColumn="true" >
    <MasterTableView DataKeyNames="" CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage" EditMode="EditForms">
        <Columns>  
     <telerik:GridBoundColumn UniqueName="id" DataField="id" HeaderText="Id"
            ForceExtractValue="InEditMode" ConvertEmptyStringToNull="true" Visible="false" >
      </telerik:GridBoundColumn>
      <telerik:GridTemplateColumn  UniqueName="Sociedad" DataField="Sociedad" HeaderText="Sociedad"
             ForceExtractValue="InEditMode" ConvertEmptyStringToNull="true"  >             
              <EditItemTemplate>  
                        <asp:DropDownList CssClass="dropdownlist" ID="ddlContainerSociedad" runat="server"></asp:DropDownList>
                         <asp:Label ID="LabelCompanyID" runat="server" Text='<%#Eval("CompanyID") %>'></asp:Label>                  
                    </EditItemTemplate>
                        <ItemTemplate>
                        <asp:Label ID="LabelCompanyID" runat="server" Text='<%#Eval("CompanyID") %>'></asp:Label>
                    </ItemTemplate>
                     <FilterTemplate>
              
               
            </FilterTemplate>
                                
             </telerik:GridTemplateColumn>
  
       <telerik:GridEditCommandColumn ButtonType="ImageButton" />         
        </Columns>  
    </MasterTableView>
    <PagerStyle Mode="NextPrevAndNumeric" />
</telerik:RadGrid>
I removed the code between the filter template tags, it solved this problem.  However I think the exception thrown could be a framework's bug since there is a conflict between the filtertemplate tag and Allowfilteringbycolumn  tag.

All the Best,
William

Tags
Grid
Asked by
william
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
william
Top achievements
Rank 1
Share this question
or