Hi Daniil
Thakns for reply,I will study your suggestion today but yesterday before post I do this with server side code and working as I want please check and tell me this approach is correct or not .
public Paging<object> RemotePagingAndFilter(int start, int limit, string sort, SortDirection dir, string filter)
{
var data = this.GetData();
FilterHeaderConditions fhc = new FilterHeaderConditions(filter);
foreach (FilterHeaderCondition condition in fhc.Conditions)
{
string dataIndex = condition.DataIndex;
FilterType type = condition.Type;
string op = condition.Operator;
object value = null;
switch (condition.Type)
{
case FilterType.Boolean:
value = condition.Value<bool>();
break;
case FilterType.Date:
switch (condition.Operator)
{
case "=":
value = condition.Value<DateTime>();
break;
case "compare":
value = FilterHeaderComparator<DateTime>.Parse(condition.JsonValue);
break;
}
break;
case FilterType.Numeric:
bool isInt = data.Count > 0 && data[0].GetType().GetProperty(dataIndex).PropertyType == typeof(int);
bool isInt64 = data.Count > 0 && data[0].GetType().GetProperty(dataIndex).PropertyType == typeof(Int64);
switch (condition.Operator)
{
case "=":
if (isInt)
{
value = condition.Value<int>();
}
else if(isInt64)
{
value = condition.Value<Int64>();
}
else
{
value = condition.Value<double>();
}
break;
case "compare":
if (isInt)
{
value = FilterHeaderComparator<int>.Parse(condition.JsonValue);
}
else
{
value = FilterHeaderComparator<double>.Parse(condition.JsonValue);
}
break;
}
break;
case FilterType.String:
value = condition.Value<string>();
break;
default:
throw new ArgumentOutOfRangeException();
}
data.RemoveAll(item =>
{
object oValue = item.GetType().GetProperty(dataIndex).GetValue(item, null);
string matchValue = null;
string itemValue = null;
if (type == FilterType.String)
{
matchValue = (string)value.ToString().ToLower();
itemValue = oValue.ToString().ToLower() as string;
}
if(type==FilterType.Numeric)
{
matchValue = (string)value.ToString().ToLower();
itemValue =Convert.ToString(oValue);
}
switch (type)
{
case FilterType.String:
return itemValue == null || itemValue.IndexOf(matchValue) < 0;
case FilterType.Numeric:
return itemValue == null || !itemValue.StartsWith(matchValue);
default:
throw new Exception("Not supported operator");
}
});
}
//-- end filtering ------------------------------------------------------------
if ((start + limit) > data.Count)
{
limit = data.Count - start;
}
List<tbl_SysMenuMaster> rangePlants = (start < 0 || limit < 0) ? data : data.GetRange(start, limit);
return new Paging<object>(rangePlants, data.Count);
}