We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Filtering ForeignKey field raises an exception

Thread ID:

Created:

Updated:

Platform:

Replies:

123329 Mar 8,2016 03:28 PM UTC Mar 10,2016 04:04 AM UTC ASP.NET MVC 3
loading
Tags: Grid
Omar Muscatello
Asked On March 8, 2016 03:28 PM UTC

Hello Syncfusion Team,
I'm working with the Grid control.

The grid show a nested entity throught:

col.Field(x => x.Categoria.Id).HeaderText("Categoria")
                                .ForeignKeyField("Id").ForeignKeyValue("Nome")
                                .DataSource(ViewBag.Categorie)
                                .EditType(EditingType.Dropdown)
                                .Add();

I want to filter this column (filtering is enabled in grid).

When I write something on the filter textbox the action called is:

[HttpPost]
        public JsonResult Lista(DataManager dm)
        {
            using (DataDbContext db = new DataDbContext())
            {
                IEnumerable data = db.Pazienti;
                DataOperations operation = new DataOperations();
                data = operation.Execute(data, dm);
                List<PazienteViewModel.Index> result = data.Cast<Paziente>().AsQueryable().OrderBy(x => x.Cognome).ThenBy(x => x.Nome).ProjectToList<PazienteViewModel.Index>();

                return Json(new { result, count = result.Count });
            }
        }

Executing this code, I get an exception on the highlighted line.

System.NullReferenceException non è stata gestita dal codice utente
  HResult=-2147467261
  Message=Riferimento a un oggetto non impostato su un'istanza di oggetto.
  Source=Syncfusion.EJ
  StackTrace:
       in Syncfusion.JavaScript.DataSources.DataOperations.PerformWhereFilter(IEnumerable dataSource, List`1 whereFilter, String condition)
       in Syncfusion.JavaScript.DataSources.DataOperations.Execute(IEnumerable dataSource, DataManager manager)
       in PazientiController.Lista(DataManager dm) in PazientiController.cs:riga 36
       in lambda_method(Closure , ControllerBase , Object[] )
       in System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
       in System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
       in System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
       in System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
       in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
       in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
       in System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
       in System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
       in System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
  InnerException: 

How can I solve this problem? What am I doing wrong?

Gowthami V [Syncfusion]
Replied On March 9, 2016 09:24 AM UTC

Hi Omar,

We have analyzed your issue and we are unable to reproduce the issue.

For your reference we have attached the sample (version 13.4.0.63) below,

http://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample-387324481.zip

Please provide us below details to reproduce the issue.

1.       Share the code example used for grid rendering.

2.       Share the version details that you have used.

3.       Reproduce the issue in the above sample.

The provide information will help to analyze the issue and provide you the response as early as possible.

Regards,

Gowthami V.


Omar Muscatello
Replied On March 9, 2016 05:20 PM UTC

Thank you Gowthami V.

Comparing your example with mine I found the problem.

I have to use x.IdCategoria and not x.Categoria.Id

So I think that there is a problem with nested entities.

Thank you again.

Gowthami V [Syncfusion]
Replied On March 10, 2016 04:04 AM UTC

Hi Omar,
 
We are happy to hear that your issue has been resolved.
 
Get back to us if you need further assistance.
 
Regards,
 
Gowthami V.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;