Hi,
I am facing an issue with remote sorting . Every time i do sorting i am getting the below exception. Please help me in resolving this issue. Also please refer the below link for sample application to recreate the issue.
https://maftp.thruinc.net/Desktop/Distro/Show/0491SXOI31B
{"Value cannot be null.\r\nParameter name: property"}
at System.Linq.Expressions.Expression.Property(Expression expression, PropertyInfo property)
at Infragistics.Web.Mvc.SortingExtensions.ApplyOrder(IQueryable source, String property, String methodName)
at Infragistics.Web.Mvc.SortingExtensions.OrderBy(IQueryable q, List`1 expressions)
at Infragistics.Web.Mvc.GridSorting.TransformDataSource(NameValueCollection queryString, IGridModel grid, IQueryable& queryable)
at Infragistics.Web.Mvc.GridModel.TransformDatasource(NameValueCollection queryString, IQueryable queryable)at Infragistics.Web.Mvc.GridModel.DataBindInternal()at Infragistics.Web.Mvc.GridModel.DataBind()
Thanks & Regards
Nagaraju P
Hello Nagaraju,
Thank you for your patience while I was looking into this.
I have noticed that you are using different version for the client scripts (version 18.2) and the MVC version (version 17.2).
Please make sure to always use a matching MVC version as different versions of both libraries are not always compatible.
Grid remote operations work out of the box only for Queryable of object that contains the related column’s as properties, for example if you modify your data object as follows:
public object GetModel() { List<Product> rows = new List<Product>(); for (int i = 0; i < 10;i++) { rows.Add(new Product() { ProductId = i, ProductName = "ProductName" + i }); } return rows.AsQueryable(); }
Where Product is class:
internal class Product { public int ProductId { get; set; } public string ProductName { get; set; } }
Then remote operations will work as expected.
If you want to use some other data type for the Qyeryable you would have to handle the remote operations manually ( https://www.igniteui.com/help/handling-remote-features-manually ).
Let me know if you encounter any issues after updating your MVC version and changing the Model type as suggested.
Regards,
Maya Kirova
Thanks for your input. But as per my requirement I do not want to use any model type. In case if I have to implement remote features manually, do I need to implement all of them or this issue exist only for sorting ,others I can still go with my existing logic. Also I dont see the ApplyOrder method in the link that you have shared. from which the exception is being thrown. Can you please help me in implementing remote sorting manually for collection of anonymous types.
Other features that depend on the columns (like filtering, groupby etc.) will also not work out of the box with Dictionary models, so if you have such features you would have to manually handle their remote operations as well.
You can refer to the following sample that manually implements remote sorting:
https://www.igniteui.com/grid/manual-remote-features-handling
It contains an ApplyOrder method that work on objects. In your case you should modify it so that it reads from your Dictionary.
Let me know if you have any questions.
Thanks for your replay.
It seems like below piece of code is throwing the error as it does not have property1. Because source.ElementType will return type System.Object for anonymous objects (just says what type it is ,does not give any information of that type), from which will not able to get properties information. Instead of that it could have been some thing like ,getting the first element from source and call GetType on it would result the type info of the element, which could give properties information what I assume.
"expression = (Expression) Expression.Property(expression, property1)"
It looks like for other features ,I dont see any such piece of code(correct me if I am wrong).
Is there a way that I can still use "GridDataSourceActionAttribute.OnActionExecuted" for all other features? and for soring implementing it manually.
May I also know "GridDataSourceActionAttribute.OnActionExecuted" does only apply the filters or it does something else too? Replacing the above code call what and all I am suppose to do?
Other features that read values based on the column keys would also try to get the related property value in order to apply the related operation for that field, so they would also fail (like remote Filtering, GroupBy etc.).
The GridDataSourceActionAttribute reads the parameters passed in the QueryString as part of the request and based on that applied the related data operation directly to the grid data. In the end the resulting data is returned as JsonResult. At this time there is no option to exclude or include specific features from the GridDataSourceActionAttribute data processing pipeline nor is it possible to modify the Request’s QueryString (as it is readonly).
Instead I would suggest that you use the grid model instead to get the JsonResult data manually. This would allow you to exclude the features that need to be implemented manually for your data type.
For example:
[ActionName("GridResults")] public ActionResult GetProducts() { var gm = ControlHtmlHelper.GetGridModel(); //remove sorting var sorting = gm.Features.First(x => x.Name == "Sorting"); gm.Features.Remove(sorting); var data = this.GetModel(); // apply sorting manually here and pass manually sorted data as data source gm.DataSource = data; gm.DataBind(); return gm.GetData(); }
Let me know if that would solve your issue.