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

[Solved] invalid postback argument after custom filtering

2 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mariusz
Top achievements
Rank 1
Mariusz asked on 27 Mar 2013, 08:54 AM
Hi

I have radgrid with custom filtering:
<script type="text/javascript">
function IconsComboBoxChanging(sender, eventArgs) {
                var item = eventArgs.get_item();
                if (item != null) {
                    var input = sender.get_inputDomElement();
                    input.value = "";
                    input.defaultValue = "";
                }
            }
function DropDownFilterLoad(sender) {
                sender.set_text("");
                var itm = sender.get_items();
                var selected = itm.getItem(sender._selectedIndex);
                var img = selected.get_imageUrl();
                var input = sender.get_inputDomElement();
                SetBackground(input, img);
            }
</script>
<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="true" OnNeedDataSource="CorrectionsGrid_NeedDataSource" [...]>
[...]
    <Columns>
        <telerik:GridTemplateColumn UniqueName="CorrectStatus" HeaderText="Status" HeaderStyle-Width="55px" Resizable="false" DataField="CorrectionAcceptState">
            <ItemTemplate>
                <asp:Image [...] />
            </ItemTemplate>
            <FilterTemplate>
                <telerik:RadComboBox ID="StatusFiletCB" Width="45px" AppendDataBoundItems="true" DropDownWidth="205px" NoWrap="true" runat="server" OnSelectedIndexChanged="CorrectStatusFilterChange" AutoPostBack="true" AllowCustomText="false" OnClientSelectedIndexChanged="IconsComboBoxChanging" OnClientLoad="DropDownFilterLoad">
                    <Items>
                        <telerik:RadComboBoxItem Value="0"[...] />
                        <telerik:RadComboBoxItem Value="1"[...] />
                        <telerik:RadComboBoxItem  Value="2" [...] />
                    </Items>
                </telerik:RadComboBox>
            </FilterTemplate>
        </telerik:GridTemplateColumn>
<telerik:GridTemplateColumn AllowFiltering="false" UniqueName="ActionColumn" HeaderText="" HeaderStyle-Width="60px"
    Resizable="false" Visible="false">
    <ItemTemplate>
       <asp:ImageButton CommandName="Reject" runat="server" CommandArgument='<%# Eval("CorrId") %>' Visible='<%# this.IsUserAllowedToAccept() %>' [...] />
    </ItemTemplate>
</telerik:GridTemplateColumn>



    [...]
    </Columns>
</telerik:RadGrid>

Code behinde:
protected void CorrectionsGrid_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    CorrectionsGrid.DataSource = new MyDataContext().Corrections;
}
 
private int? GetValueOfCorrectionAcceptStateFilter()
{
    var regSearch = Regex.Match(CorrectionsGrid.MasterTableView.FilterExpression, @".*\(it\.CorrectionAcceptState = (?<filterVal>[1-3])\).*");
    if (regSearch.Success)
        return Int32.Parse(regSearch.Groups["filterVal"].Value);
    else
        return null;
}
 
protected void CorrectStatusFilterChange(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
    string filterExpression = CorrectionsGrid.MasterTableView.FilterExpression;
 
    var currentcFilter = GetValueOfCorrectionAcceptStateFilter();
    if (currentcFilter.HasValue)
        filterExpression = filterExpression.Replace("(it.CorrectionAcceptState = " + currentcFilter.Value + ")", string.Empty);
 
    if (Int32.Parse(e.Value) > 0)
        filterExpression = (filterExpression.Trim().Length > 0 ? filterExpression + " AND " : "")
                            + "(it.CorrectionAcceptState = " + e.Value + ")";
    CorrectionsGrid.MasterTableView.FilterExpression = filterExpression;
    CorrectionsGrid.MasterTableView.Rebind();
}

everything works fine until I set the filter and call out rejection - invalid postback or callback argument. where making a mistake?

2 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 01 Apr 2013, 07:09 AM
Hello Mariusz,

Please try to set "EnableLinqExpressions = false" for the RadGrid control and verify if this helps.

Regards,
Maria Ilieva
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
Mariusz
Top achievements
Rank 1
answered on 04 Apr 2013, 10:36 AM
I found solutions by changing javascript function DropDownFilterLoad
using sender.get_inputDomElement().value = "";  instead of sender.set_text(""); resolved issue.

thanks for tip
Tags
Grid
Asked by
Mariusz
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Mariusz
Top achievements
Rank 1
Share this question
or