如果使用多个分组,jqgrid 高级搜索可以生成搜索条件,如
{"groupOp":"AND","rules":[],"groups":[{"groupOp":"AND","rules":[{"field":"Nimi","op":"cn","data":"kk"},{"field":"Nimi","op":"cn","data":"kkk"}],"groups":[]}]}
尝试在 ASP .NET MVC2 中使用反序列化它
var serializer = new JavaScriptSerializer();
var filtersList = serializer.Deserialize<Filter>(_filters);
class Filter
{
public GroupOp groupOp { get; set; }
public List<Rule> rules { get; set; }
public List<Filter> groups { get; set; }
}
class Rule
{
public string field { get; set; }
public Operations op { get; set; }
public string data { get; set; }
}
enum GroupOp
{
AND,
OR
}
enum Operations
{
eq, // "equal"
ne, // "not equal"
lt, // "less"
le, // "less or equal"
gt, // "greater"
ge, // "greater or equal"
bw, // "begins with"
bn, // "does not begin with"
@in, // "in"
ni, // "not in"
ew, // "ends with"
en, // "does not end with"
cn, // "contains"
nc // "does not contain"
}
返回空的 filtersList.rules 属性
如何从这些数据中得到正确的规则?
更新
筛选
{"groupOp":"AND","rules":[{"field":"Nimi","op":"cn","data":""},
{"field":"Nimi","op":"cn","data":""},{"field":"Nimi","op":"cn","data":""}],
"groups":[{"groupOp":"AND","rules":[],"groups":[]},{"groupOp":"AND","rules":
[{"field":"Nimi","op":"cn","data":""}],"groups":[{"groupOp":"AND","rules":[],
"groups":[{"groupOp":"AND","rules":[],"groups":[]},{"groupOp":"AND","rules":[],"groups":[{"groupOp":"AND","rules":[],"groups":[{"groupOp":"AND","rules":[],
"groups":[{"groupOp":"AND","rules":[],"groups":[{"groupOp":"AND","rules":[],"groups":[]},{"groupOp":"AND","rules":[],"groups":[]}]}]}]}]},{"groupOp":"AND","rules":[{"field":"Nimi","op":"cn","data":""}],"groups":[{"groupOp":"AND","rules":[{"field":"Nimi","op":"cn","data":""},{"field":"Nimi","op":"cn","data":""}],
"groups":[]}]},{"groupOp":"AND","rules":[],"groups":[]},{"groupOp":"AND","rules":[],"groups":[]},{"groupOp":"AND","rules":[],"groups":[]},{"groupOp":"AND","rules":[],"groups":[]}]}]}]}
在引用的答案中使用更新部分的代码仍然会产生无效的 where
((klient.Nimi ILIKE ('%' || E'' || '%') ESCAPE '!')AND(klient.Nimi ILIKE
('%' || E'' || '%') ESCAPE '!')AND(klient.Nimi ILIKE ('%' || E'' || '%') ESCAPE '!'))AND
((((klient.Nimi ILIKE ('%' || E'' || '%') ESCAPE '!'))AND(((((())))AND(((klient.Nimi ILIKE ('%' || E'' || '%') ESCAPE '!'))AND(((klient.Nimi ILIKE ('%' || E'' || '%') ESCAPE '!')
AND(klient.Nimi ILIKE ('%' || E'' || '%') ESCAPE '!'))))))))