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

Filter button causes postback

9 Answers 265 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Barbaros Saglamtimur
Top achievements
Rank 1
Barbaros Saglamtimur asked on 07 Oct 2011, 12:44 PM
I am using version 2011.2.1004.40.

When I enter some value inside filter textbox and push filter button, instead of opening filter menu drop down, It raises postback with filtering "contains". If I do not enter value into textbox and click filter button it opens the menu as expected.

Any thoughts?

9 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 10 Oct 2011, 03:52 AM
Hello Barbaros,

Try setting the AutoPostBackOnFilter property for the column to false and see if it makes any difference.

All the best,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Barbaros Saglamtimur
Top achievements
Rank 1
answered on 10 Oct 2011, 07:34 AM
I have already tried it but failed.

<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AutoGenerateColumns="False"
    CellSpacing="0" GridLines="None" OnNeedDataSource="RadGrid1_NeedDataSource">
    <MasterTableView>
        <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
            <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
            <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridBoundColumn DataField="TemplateId" AutoPostBackOnFilter="false" FilterControlAltText="Filter column column"
                UniqueName="column">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="TemplateName" FilterControlAltText="Filter column1 column"
                UniqueName="column1">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="TemplateDescription" FilterControlAltText="Filter column2 column"
                UniqueName="column2">
            </telerik:GridBoundColumn>
        </Columns>
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
    </HeaderContextMenu>
</telerik:RadGrid>

As you can see there is nothing special and it is working as expected when I downgrade it to version 915.
0
Iana Tsolova
Telerik team
answered on 10 Oct 2011, 01:06 PM
Hello Barbaros,

I followed your steps in this sample but was not able to replicate the issue. I can successfully enter some text in the filter textbox and select filter function from the menu. Afterward filtering is applied as expected without postbacks fired meanwhile. Can you try it and let me know if I missed something out?

Best wishes,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Barbaros Saglamtimur
Top achievements
Rank 1
answered on 10 Oct 2011, 03:03 PM
Thanks for your help. I have tried your sample but problem still exists on my side. What I have found is onclick javascript function is different between version 915 and 1004.

915 (Working)
onclick="$find("RadGrid1")._showFilterMenu("RadGrid1_ctl00", "TemplateName", event); return false;__doPostBack('RadGrid1$ctl00$ctl02$ctl02$Filter_TemplateName','')"

1004
onclick="$find("RadGrid1")._showFilterMenu("RadGrid1_ctl00", "TemplateName", event); return false;"

So I thought something may have changed for showFilterMenu function too, but I haven't find _showFilterMenu function in axd files yet.

I am totally confused.
0
Iana Tsolova
Telerik team
answered on 11 Oct 2011, 02:56 PM
Hello Barbaros,

The sample I sent to you uses the 1004 version. Can you confirm you are replicating the issue running it directly as a web site in your Visual Studio? If yes, please elaborate on the steps you perform.

Greetings,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Ralf
Top achievements
Rank 1
answered on 20 Dec 2011, 06:33 PM
Hi,

here I get the same behavior. Clicking the filter button, without entered text before, the filter menu will open. No postback was performed. So far, so good.
Clicking the filter button, with entered text before, a postback will be raised, the data will be filtered by using the filter "EqualsTo" and afterwards the filter menu opens.

We are using the grid in a dynamic way (webpart including asp update panel in a SharePoint context).
AutoPostbackOnFilter was set to false, and the default filter option was set to "NoFilter". 
The behavior occurs at every column. For text columns we have implemented a workaround by using the "Google like" column filtering and client side events. For numeric and datetime columns we are using the standard filtering.

The Telerik version is: 2011.3.1115.35

If I take a look closer into the rendered html source, I can figure out the following:
<INPUT id=ctl00_m_ResultList1_ResultList1ResultGrid_GridViewRESFC_ctl00_ctl02_ctl02_Filter_3c04456d-754d-48f4-9506-4684f5302915 class=rgFilter title=Filter
onclick='$find("ctl00_m_ResultList1_ResultList1ResultGrid_GridViewRESFC")._showFilterMenu("ctl00_m_ResultList1_ResultList1ResultGrid_GridViewRESFC_ctl00", "3c04456d-754d-48f4-9506-4684f5302915", event);
return false;
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$m$ResultList1$ResultList1ResultGrid$GridViewRESFC$ctl00$ctl02$ctl02$Filter_3c04456d-754d-48f4-9506-4684f5302915", "", true, "", "", false, false))'
name=ctl00$m$ResultList1$ResultList1ResultGrid$GridViewRESFC$ctl00$ctl02$ctl02$Filter_3c04456d-754d-48f4-9506-4684f5302915 type=submit>


Here is the column definition for the GridNumericColunn:

public class NumberColumn: GridNumericColumn
{
#region Fields (1) 
 
SPField _field;
 
#endregion Fields 
 
#region Constructors (1) 
 
/// <summary>
/// Initializes a new instance of the <see cref="NumberColumn"/> class.
/// </summary>
/// <param name="field">The field.</param>
public NumberColumn(SPField field)
{
    this.AllowSorting = true;
    this.DataField = field.Id.ToString();
    this.HeaderText = field.Title;
    this.SortExpression = field.Id.ToString();
    this.HeaderTooltip = "";
    this.NumericType = Telerik.Web.UI.NumericType.Number;
    this.AutoPostBackOnFilter = false;
    this.CurrentFilterFunction = GridKnownFunction.NoFilter;
    this.AllowFiltering = true;
 
    _field = field;
 
}
 
#endregion Constructors


How to get the correct behavior (no postback before a filterfunction was selected)?

Regards,
Ralf



0
Tsvetina
Telerik team
answered on 22 Dec 2011, 12:47 PM
Hi Ralf,

Your scenario seems slightly different having in mind that you use an inherited column. Would it be possible that you create a sample runnable project and send it to us in a formal support ticket? We will debug it locally and let you know what causes the problem and how to fix it.

Regards,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Ralf
Top achievements
Rank 1
answered on 22 Dec 2011, 01:32 PM
Hi Tsvetina,

I'm sorry, our projekt is too complexe to create a sample. Is it possible to handle the events client side? I need to do a postback only if a filter option was selected from the filtermenu. And if enter was pressed inthe input box I need to check first if the current filterfuntion is not "NoFilter", and then I will raise a postback. Or, if "NoFilter" is the current filterfunction, the filtermenu should opens. Is this possible to do client side by using javascript?

Best regards,
Ralf
0
Tsvetina
Telerik team
answered on 23 Dec 2011, 02:23 PM
Hi Ralf,

You can try using the OnCommand client event of RadGrid for this purpose. You can use the grid client API to check the current filter function for the column and if it is NoFilter, to cancel out the event:
OnCommand

Sample code:
function clearFiltering(sender, args) {
    var cmdName = args.get_commandName();
        if(cmdName=="Filter")
        {
        var mst = sender.get_masterTableView();
        var clmn = mst.getColumnByUniqueName("ColName");
        var flf = clmn.get_filterFunction();
        if (flf == "NoFilter") {
            args.set_cancel(true);
        }
    }
}

However, I am still not sure why your grid postbacks without AutoPostBackOnFilter="true". And as it is not expected behavior, it is not sure whether this approach will work. So, let us know how this goes for you or if you notice any more details about the postback problem.

Regards,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Barbaros Saglamtimur
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Barbaros Saglamtimur
Top achievements
Rank 1
Ralf
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or