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

Filter and Sort Problems RadGrid Q1 2010 Trial

1 Answer 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ysea
Top achievements
Rank 1
ysea asked on 24 Mar 2010, 05:33 AM
I want to upgrade from telerik 2006 to telerik Web 2010 so I use version trial Q1 2010.
I created columns of RadGrid in code behind (OnInit).
Here is my code
In aspx page
<telerik:RadGrid  ID = "gridTemp" runat = "server" AutoGenerateColumns="false"
        OnNeedDataSource="OnNeedDataSource" OnItemDataBound="gridTemp_ItemDataBound">                     
            <MasterTableView AutoGenerateColumns="false" AllowSorting="true" AllowFilteringByColumn="true"
                    EnableViewState="false" EnableColumnsViewState="false">
                <AlternatingItemStyle CssClass="CssAlternatingItem" />
                <ItemStyle CssClass="CssItem" />
                <NoRecordsTemplate><%=ML("Norecordtodiplay")%></NoRecordsTemplate>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnColumnResized="ChangeStatus();" OnColumnSwapped="ChangeStatus();" />
            </ClientSettings>           
       </telerik:RadGrid >      



In aspx.cs page
..............
foreach (Column column in caseOverviewXml.ListColumn)
                                {                                  
                                    if (string.Compare(column.Name.ToLower(), "allconversationsid") == 0)
                                    {
                                        DynamicTemplate mt = new DynamicTemplate(ListItemType.Item);
                                        Label lblColor = new Label();
                                        lblColor.ID = "lblColor";
                                        mt.AddControl(lblColor, string.Empty, string.Empty);
                                        GridTemplateColumn templateColumn = new GridTemplateColumn();
                                        templateColumn.ItemTemplate = mt;
                                        templateColumn.UniqueName = column.Name;
                                        templateColumn.OrderIndex = orderIndex;
                                        templateColumn.AllowFiltering = false;

                                        switch (Request.QueryString["lang"])
                                        {
                                            case "de":
                                                templateColumn.HeaderText = column.Caption_de;
                                                break;
                                            case "en":
                                                templateColumn.HeaderText = column.Caption_en;
                                                break;
                                            case "fr":
                                                templateColumn.HeaderText = column.Caption_fr;
                                                break;
                                            case "it":
                                                templateColumn.HeaderText = column.Caption_it;
                                                break;
                                            default:
                                                templateColumn.HeaderText = column.Caption_en;
                                                break;
                                        }
                                        gridTemp.MasterTableView.Columns.Add(templateColumn);
                                    }
                                    else
                                    {
                                        GridHyperLinkColumn boundColumn = new GridHyperLinkColumn();
                                        column.Name = column.Name.Replace("@LANG", Request.QueryString["lang"]);
                                        
                                        boundColumn.UniqueName = column.Name;
                                        boundColumn.DataTextField = column.Name;

                                        boundColumn.ShowSortIcon = true;
                                        boundColumn.SortExpression = column.Name;

                                        boundColumn.ItemStyle.Wrap = true;                                        
                                        boundColumn.OrderIndex = orderIndex;
                                        boundColumn.ShowFilterIcon = false;
                                        boundColumn.AllowFiltering = true;
                                        boundColumn.CurrentFilterFunction = GridKnownFunction.Contains;
                                        boundColumn.AutoPostBackOnFilter = true;
                                       
                                        switch (Request.QueryString["lang"])
                                        {
                                            case "de":
                                                boundColumn.HeaderText = column.Caption_de;
                                                break;
                                            case "en":
                                                boundColumn.HeaderText = column.Caption_en;
                                                break;
                                            case "fr":
                                                boundColumn.HeaderText = column.Caption_fr;
                                                break;
                                            case "it":
                                                boundColumn.HeaderText = column.Caption_it;
                                                break;
                                            default:
                                                boundColumn.HeaderText = column.Caption_en;
                                                break;
                                        }

                                        boundColumn.DataNavigateUrlFormatString =
                                            "/Default.aspx?caseId={0}&ConversationID={1}&lang=" + Request.QueryString["lang"];
                                        boundColumn.DataNavigateUrlFields = new string[]
                                                                        {
                                                                            "CaseId", "NavigationLastConversationId"
                                                                        };
                                        if (!string.IsNullOrEmpty(column.Width))
                                        {
                                            boundColumn.HeaderStyle.Width =
                                                new Unit(ConvertHelper.ToDouble(column.Width));
                                        }
                                        gridTemp.MasterTableView.Columns.Add(boundColumn);

                                    }   // end else

                                    orderIndex++;
                                }   // end foreach

Filter problem : I cannot press Enter to filter because it not postback
Sort problem : The first it sort success, in the second or the third it occur error :"

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation."


Could you help me ?

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 25 Mar 2010, 10:34 AM
Hello,

I suggest you check out the following forum thread and see if it helps to avoid this error:
http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-sorting-error.aspx

Regards,
Pavlina
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
ysea
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or