Wenn mehrere Gruppierung deserialisieren jqGrid verwendet wird, jqGrid erweiterte Suchkriterien Suche generieren können wiewie mehrere Gruppensuchkriterien in asp .net MVC2
{"groupOp":"AND","rules":[],"groups":[{"groupOp":"AND","rules":[{"field":"Nimi","op":"cn","data":"kk"},{"field":"Nimi","op":"cn","data":"kkk"}],"groups":[]}]}
es in ASP .NET MVC2 mit
deserialisieren Der Versuch, 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"
}
kehrt leer filtersList.rules Eigenschaft
Wie korrekte Regeln aus diesen Daten zu bekommen?
Update
Filter
{"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":[]}]}]}]}
von aktualisierten Teil in referenzierten Antwort unter Verwendung von Code erzeugt noch ungültig, wo
((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 '!'))))))))
Ich habe versucht, aktualisierte Teil. Für leere Filter '{" groupOp ":" AND "," Regeln ": []," groups ": []}' gibt es null – Andrus
@Andrus: Ist es nicht korrekt? Um genau zu sein ist es 'neuer Filter {groupOp = GroupOp.AND, rules = new Liste (0), groups = new Liste (0)};'. Es ist also genau wie deine Eingabedaten. Welchen deserialisierten Wert erwarten Sie für die Eingabe? –
Oleg
Ich aktualisierte Frage und fügte Testfall hinzu, der ungültigen where-Klausel zurückgibt, die UPDATED-Teil von http://stackoverflow.com/a/10052736/315935 – Andrus