Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
GridDataSourceActionAttribute throwing error OnActionExecuted
posted

Hi,

I  Want to know what exactly OnActionExecuted action of GridDataSourceActionAttribute  does?

we were using model class to bind data to view in our project as below

In Controller:

System.Type modelType = Type.GetType("System.Collections.Generic.List`1[" + modelClass + "]")

// here model class is public class which has all properties which we want to display in gri.d.

string json = Newtonsoft.Json.JsonConvert.SerializeObject(dataTable);
var model = Newtonsoft.Json.JsonConvert.DeserializeObject(json, modelType);

return ((IList)model).AsQueryable();

after controller action gets executed the below code is getting called.

public void OnActionExecuted(ActionExecutedContext filterContext)
{
var viewResult = filterContext.Result as ViewResult;
GridDataSourceActionAttribute igAttribute = new GridDataSourceActionAttribute();
igAttribute.OnActionExecuted(filterContext);
}

This was working fine for us when we perform sorting and grouping with the above code.

Now we are removing the model class and binding data directly to grid as below

In Controller:

string json = Newtonsoft.Json.JsonConvert.SerializeObject(dataTable);
var model = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(json)

return ((IList)model).AsQueryable();

public void OnActionExecuted(ActionExecutedContext filterContext)
{
var viewResult = filterContext.Result as ViewResult;
GridDataSourceActionAttribute igAttribute = new GridDataSourceActionAttribute();
igAttribute.OnActionExecuted(filterContext);
}

with this code changes sorting and grouping is not working for me. gettinng argumentnullexception (value cannot be null).

i cannot debug the method also for more information.

Can anyone help me to figure out why this issue is happening?

Thanks,

Shwetha

Parents Reply Children
No Data