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

Filter with CheckBox list problem

1 Answer 270 Views
Grid
This is a migrated thread and some comments may be shown as answers.
diego
Top achievements
Rank 1
diego asked on 17 May 2017, 03:06 PM

hello

i am trying to implement a radgrid with filtering controls; one (or more, hopefully) column should be filtered using a checkbox list

here is the ascx code:

<telerik:RadGrid runat="server" AllowFilteringByColumn="True" FilterType="Combined" DataSourceID="SqlDataSource1"
    AllowPaging="True" PageSize="10" CellSpacing="0" GridLines="None" Skin="Bootstrap" HeaderStyle-Font-Bold="true"
     AutoGenerateColumns="False" ID="subFilesGrid" EnableViewState="true"
        OnPageIndexChanged="subFilesGrid_OnPageIndexChanged"
        onitemcommand="subFilesGrid_ItemCommand" OnFilterCheckListItemsRequested="subFilesGrid_FilterCheckListItemsRequested">
     
<MasterTableView DataKeyNames="nome">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
 
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
 
    <Columns>
        <telerik:GridButtonColumn Text="Download" CommandName="dloadFile" UniqueName="dcCol"></telerik:GridButtonColumn>
        <telerik:GridBoundColumn DataField="originalname" HeaderText="File Name" UniqueName="FileName" HeaderStyle-Width="150px" AllowFiltering="false">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="dinfo" HeaderText="Description" HeaderStyle-Width="180px" UniqueName="column" AllowFiltering="false">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="FileType" HeaderText="File Type" HeaderStyle-Width="150px" UniqueName="FileType" FilterCheckListEnableLoadOnDemand="true">
        </telerik:GridBoundColumn>
        <telerik:GridDateTimeColumn DataField="date" HeaderText="Submission Date" HeaderStyle-Width="180px"
            PickerType="DatePicker" FilterDateFormat="yyyy-MM-dd" DataFormatString="{0:yyyy-MM-dd HH:mm}">
        </telerik:GridDateTimeColumn>
        <telerik:GridTemplateColumn DataField="sName" HeaderText="Submitter" UniqueName="column2">
            <ItemTemplate>
                <%# SetSubmitter(Eval("sName"))%>
            </ItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn DataField="status" HeaderText="Status" UniqueName="column3">
            <ItemTemplate>
                <%# SetStatus(Eval("status"))%>
            </ItemTemplate>
        </telerik:GridTemplateColumn>
        
    </Columns>
 
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
 
<FilterMenu EnableImageSprites="False">
<WebServiceSettings>
<ODataSettings InitialContainerName=""></ODataSettings>
</WebServiceSettings>
</FilterMenu>
 
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
<WebServiceSettings>
<ODataSettings InitialContainerName=""></ODataSettings>
</WebServiceSettings>
</HeaderContextMenu>
     
</telerik:RadGrid>

 and here is code-behind for filling the checkbox list

protected void subFilesGrid_FilterCheckListItemsRequested(object sender, GridFilterCheckListItemsRequestedEventArgs e)
        {
            string DataField = (e.Column as IGridDataColumn).GetActiveDataField();
            e.ListBox.Items.Clear();
            e.ListBox.AppendDataBoundItems = false;
            /*e.ListBox.DataSource = GetDataTable(DataField);
            e.ListBox.DataKeyField = DataField;
            e.ListBox.DataTextField = DataField;
            e.ListBox.DataValueField = DataField;
            e.ListBox.DataBind();*/
            string query = "SELECT type as FileType FROM [ICOS].[dbo].[FileType] where id_filetype!=20";
            // string.Format("SELECT type as FileType FROM [ICOS].[dbo].[FileType] where id_filetype!=20", field);
 
            SqlConnection cn = new SqlConnection(conn);
            cn.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = cn;
            cmd.CommandText = query;
            SqlDataReader rd = cmd.ExecuteReader();
            while (rd.Read())
            {
                e.ListBox.Items.Add(new RadListBoxItem(rd["FileType"].ToString()));
            }
            e.ListBox.DataTextField = DataField;
            e.ListBox.DataValueField = DataField;
            e.ListBox.DataBind();
            rd.Close();
            cn.Close();
            e.ListBox.ShowCheckAll = false;
             
        }

now, when loading the page, an unexpected item is displayed: ResourceNotFound#CheckListBox:CheckAll (you can see it here)

i have followed the steps showed in this page

Thanx in advance

Diego

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 22 May 2017, 08:22 AM
Hello Diego,

You should also set the FilterCheckListEnableLoadOnDemand property to the columns. You can also check the Excel-like filtering for a live sample of the same binding technique:
http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/excel-like-filtering/defaultcs.aspx?skin=Material

Regards,
Eyup
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
diego
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or