I'm using Data Table as data source for IgGrid. When I'm trying to do remote sorting I'm getting error
ArgumentNullException: Value cannot be null.
System.Linq.Expressions.Expression.Property(Expression expression, PropertyInfo property) +6153565 Infragistics.Web.Mvc.SortingExtensions.ApplyOrder(IQueryable source, String property, String methodName)
I'm converting data table into IQueryable<Object> like this
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>(); Dictionary<string, object> row = null; foreach (DataRow dr in dataTable.Rows) { row = new Dictionary<string, object>(); foreach (DataColumn col in dataTable.Columns) row.Add(col.ColumnName, dr[col] == DBNull.Value ? string.Empty : dr[col]); rows.Add(row); } return rows.AsQueryable<object>();
Here I cannot map my datatable into any specific model because datatable columns are getting change with input request.
Please suggest anyway to do remote sorting with data table as data source without creating any static model class.
Thanks!
Manish
Hi Manish,
I'm not sure why this exception is thrown. Can you please share your code for creating the grid? What model are you passing to the grid? Any other related information could be of help. Thank you.
JS code looks like
(function () {$('#igGridID').igGrid({ dataSource: '/App/screen/GridDataSourceBind?frmId=2723,
features: [ { filterExprUrlKey: 'filter', filterLogicUrlKey: 'filterLogic', name: 'Filtering', type: 'local', caseSensitive: false },{ sortUrlKey: 'sort', sortUrlKeyAscValue: 'asc', sortUrlKeyDescValue: 'desc', name: 'Sorting', type: 'remote', mode: 'multiple'},.....
MVC action for data Source looks like this
[GridDataSourceAction]
public ActionResult GridDataSourceBind(int frmId)
{
DataTable dataTable = //fetch it from BL logic
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>(); Dictionary<string, object> row = null; foreach (DataRow dr in dataTable.Rows) { row = new Dictionary<string, object>(); foreach (DataColumn col in dataTable.Columns) row.Add(col.ColumnName, dr[col] == DBNull.Value ? string.Empty : dr[col]); rows.Add(row); } return View(rows.AsQueryable<object>());
}