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

Filtering Issues using FilterCheckListEnableLoadOnDemand, BatchEdit, & TemplateColumn

6 Answers 209 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pat
Top achievements
Rank 1
Pat asked on 01 Sep 2015, 02:45 AM

I'm in the process of implementing a grid that requires the FilterCheckList (like Excel) and BatchEditing (which requires GridTemplateColumn). In the grid below, the columns State & FullName work just fine, but once i turned the column "Days" into a template column, the filtering on that column stopped working. Any ideas? Currently using 2014.1.225.40. Thanks!

ASP.NET

<telerik:RadGrid ID="gridData" runat="server" Skin="Telerik" OnNeedDataSource="NeedDataSource_Data"
    AutoGenerateColumns="false" AllowSorting="true" AllowFilteringByColumn="true" ShowHeader="true" ShowFooter="true" Width="100%"
     OnFilterCheckListItemsRequested="RadGrid1_FilterCheckListItemsRequested" FilterType="CheckList" GridLines="Both" AllowPaging="false">
    <GroupingSettings CaseSensitive="false" />
    <MasterTableView DataKeyNames="ID, Days" CommandItemDisplay="Top" EditMode="Batch">
        <BatchEditingSettings EditType="Row" />
        <Columns>
            <telerik:GridBoundColumn DataField="FullName" SortExpression="FullName" HeaderText="Name" FilterCheckListEnableLoadOnDemand="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false"></telerik:GridBoundColumn>
            <telerik:GridTemplateColumn DataField="Days" HeaderText="Idle" FilterCheckListEnableLoadOnDemand="true"
                AllowFiltering="true" SortExpression="Days" AutoPostBackOnFilter="true" UniqueName="Days">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "Days") %>
                </ItemTemplate>
                <EditItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "Days") %>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn DataField="State" HeaderText="State" FilterCheckListEnableLoadOnDemand="true" ></telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#

protected void RadGrid1_FilterCheckListItemsRequested(object sender, GridFilterCheckListItemsRequestedEventArgs e)
        {
            string DataField = e.Column.DataField;
            DataSet ds = (DataSet)Cache[cacheKey];
            List<object> list = (from row in ds.Tables[0].AsEnumerable() select row[DataField]).Distinct().ToList();
             
            DataTable dtResults = new DataTable();
            dtResults.Columns.Add(DataField);
            DataRow drResult;
            foreach(object obj in list)
            {
                drResult = dtResults.NewRow();
                drResult[DataField] = obj;
                dtResults.Rows.Add(drResult);
            }
 
            e.ListBox.DataSource = dtResults.AsEnumerable().Where(x => !x[DataField].ToString().IsNullOrEmpty()).OrderBy(y => y[DataField]).CopyToDataTable();
            e.ListBox.DataKeyField = DataField;
            e.ListBox.DataTextField = DataField;
            e.ListBox.DataValueField = DataField;
            e.ListBox.DataBind();
        }

6 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 02 Sep 2015, 07:30 PM
Hi Pat,

With Batch Editing it is not supported to have Bind expressions in the EditItemTemplate, because the BatchEditingManager will retrieve the value from the ItemTemplate internally and will set it to the editor. If you need that column to be read only you could remove the EditItemTemplate. If that does not helps and if you have enabled AJAX, you could try to inspect your browser's console and see if there are any JavaScript errors present on the page that could break the built-in functionality of the control.

Let me know if the above suggestions resolved the issue.


Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Pat
Top achievements
Rank 1
answered on 08 Sep 2015, 10:41 PM

Hey Konstantin,

Any idea if this is the same issue with inline editing as well (since it requires an EditItemTemplate)?

Can you see this issue being fixed in any upcoming release?

Thanks!

 - Pat

0
Konstantin Dikov
Telerik team
answered on 11 Sep 2015, 10:22 AM
Hi Pat,

As I have mentioned, with Batch Editing it is not supported to have Bind expression within the EditItemTemplate. This is not a bug, but rather a limitation with the edit mode, because the internal logic of the Batch Editing Manager will retrieve the value from the ItemTemplate on the client.

Since you do not have an editor control within your EditItemTemplate and you just want to display the value, you should remove the EditItemTemplate or place an editor (like RadTextBox, RadNumericTextBox, etc.).


Best Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Pat
Top achievements
Rank 1
answered on 11 Sep 2015, 01:49 PM

Hey Konstantin,

I guess i'm just misunderstanding - If you're saying the Batch Editing Manager is ​retrieving values from the ItemTemplate (below my ItemTemplate is being populated for the value Days by DataBinder.Eval), why ​would this not work? Note, it doesn't hit my RadGrid1_FilterCheckListItemsRequested method when clicking on the filter button.

Also, I have a RadComboBox in the EditItemTemplate now (see below). I posted the original example code to show that as soon as i switched from a GridBoundColumn to a GridTemplateColumn, the checkbox filtering stopped working.

<telerik:GridTemplateColumn DataField="Days" HeaderText="Idle" FilterCheckListEnableLoadOnDemand="true" AllowFiltering="true" SortExpression="Days" AutoPostBackOnFilter="true" UniqueName="Days">
   <ItemTemplate>
      <%# DataBinder.Eval(Container.DataItem, "Days") %>
   </ItemTemplate>
   <EditItemTemplate>
      <telerik:RadComboBox ID="ddlDays" runat="server" DataValueField="Day" DataTextField="DayDisplay"></telerik:RadComboBox>
   </EditItemTemplate>
</telerik:GridTemplateColumn>

 - Pat

0
Konstantin Dikov
Telerik team
answered on 12 Sep 2015, 10:06 AM
Hello Pat,

The CheckList Filtering functionality for the template column is working as expected on my side. Following is a very simple example that works with our latest version:
<telerik:RadGrid ID="gridData" runat="server" Skin="Telerik" OnNeedDataSource="RadGrid1_NeedDataSource"
    AutoGenerateColumns="false" AllowSorting="true" AllowFilteringByColumn="true" ShowHeader="true" ShowFooter="true" Width="100%"
    OnFilterCheckListItemsRequested="gridData_FilterCheckListItemsRequested" FilterType="CheckList" GridLines="Both" AllowPaging="false">
    <GroupingSettings CaseSensitive="false" />
    <MasterTableView DataKeyNames="ID, Days" CommandItemDisplay="Top" EditMode="Batch">
        <BatchEditingSettings EditType="Row" />
        <Columns>
            <telerik:GridBoundColumn DataField="ID" SortExpression="ID" HeaderText="Name" FilterCheckListEnableLoadOnDemand="true"
                AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false"></telerik:GridBoundColumn>
            <telerik:GridTemplateColumn DataField="Days" HeaderText="Idle" FilterCheckListEnableLoadOnDemand="true"
                AllowFiltering="true" SortExpression="Days" AutoPostBackOnFilter="true" UniqueName="Days">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "Days") %>
                </ItemTemplate>
                <EditItemTemplate>
                    <telerik:RadComboBox ID="ddlDays" runat="server" DataValueField="Day" DataTextField="DayDisplay"></telerik:RadComboBox>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

And the code-behind:
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    DataTable table = new DataTable();
    table.Columns.Add("ID", typeof(int));
    table.Columns.Add("Days", typeof(string));
    for (int i = 0; i < 5; i++)
    {
        table.Rows.Add(i, "Days" + i);
    }
 
    (sender as RadGrid).DataSource = table;
}
 
protected void gridData_FilterCheckListItemsRequested(object sender, GridFilterCheckListItemsRequestedEventArgs e)
{
    if (e.Column.UniqueName == "Days")
    {
        DataTable table = new DataTable();
        table.Columns.Add("Days", typeof(string));
        for (int i = 0; i < 5; i++)
        {
            table.Rows.Add("Days" + i);
        }
 
        e.ListBox.DataTextField = "Days";
        e.ListBox.DataValueField = "Days";
        e.ListBox.DataSource = table;
        e.ListBox.DataBind();
    }
}

Please note that in the above example the RadComboBox in the EditItemTemplate is not bound to any data source (which should be handled within the OnPreRender event of the grid or by setting the DataSourceID property), but in should not be relevant to the issue that you are facing.

If further assistance is needed on this matter, please open a regular support ticket and attach a sample, runnable project that replicates the problem, so we can test it locally, or modify the above example, so it could reproduce the same issue.


Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Pat
Top achievements
Rank 1
answered on 19 Sep 2015, 07:23 PM

Hey Konstantin,

Thanks for the feedback. Originally the above example did not work for me using version 2014.1.403.40, but upgrading to 2015.2.826.40 made it work.

Thanks again for the help, it looks like upgrading dlls did the trick.

 - Pat

Tags
Grid
Asked by
Pat
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Pat
Top achievements
Rank 1
Share this question
or