public IEnumerable <FilterOption> GetFilterOptions(string modelName) { var modelType = Type.GetType(modelName, false, true); var buildIndexMethod = _viewBuilder.GetType().GetMethod("GetIndexFilterOptions"); var genericMethod = buildIndexMethod.MakeGenericMethod(modelType); var filterOptions = genericMethod.Invoke(_viewBuilder, null) as IEnumerable <FilterOption>; return(filterOptions); }
/// <summary> /// Calls the GetIndexFilterOptions on the ViewBuilder and returns the results /// </summary> /// <param name="controller"></param> /// <param name="modelName">The Fully Qualified Assembly Name of the model</param> /// <param name="viewBuilder">An ICrudViewBuilder implementation</param> /// <param name="visitors">Any IFilterOptionVisitors to be passed to the ViewBuilder</param> /// <returns></returns> public static IEnumerable <FilterOption> GetFilterOptions(this IIndexController controller, string modelName, ICrudViewBuilder viewBuilder, params IFilterOptionVisitor[] visitors) { var modelType = Type.GetType(modelName, false, true); var buildIndexMethod = viewBuilder.GetType().GetMethod("GetIndexFilterOptions"); var genericMethod = buildIndexMethod.MakeGenericMethod(modelType); var filterOptions = genericMethod.Invoke(viewBuilder, new object[] { visitors }) as IEnumerable <FilterOption>; return(filterOptions); }
public ActionResult RefreshTableBody(int?page, int?pageSize, string sortKey, string sortDirection, IEnumerable <string> filterKeys, IEnumerable <string> filterValues, string searchQuery, string modelName) { var modelType = Type.GetType(modelName, false, true); var buildIndexMethod = _viewBuilder.GetType().GetMethod("BuildIndexView"); var genericMethod = buildIndexMethod.MakeGenericMethod(modelType); var view = genericMethod.Invoke(_viewBuilder, new object[] { page, pageSize, sortKey, sortDirection, filterKeys, filterValues, searchQuery, null }) as IndexView; var tableHtml = RenderPartial(view.Table, "_TableBody"); var pagerHtml = RenderPartial(view.Pager, "_Pager"); return(Json(new { table = tableHtml, pager = pagerHtml }, JsonRequestBehavior.AllowGet)); }