Hi
Nick G,
We have checked your reported query and
prepared a sample based on your requirements. Using the ajax post in the button click event, you can get
the QueryBuilder rule using the getValidRules method and send the rule from the
client to the server. In server side, we have compared the created rule with
the Rule object by checking whether the rule object has field, label, operator,
and value properties, and finally, you can get true or false in the
isRulesProperlyFramed variable. Please find the following code snippet and
sample.
[Client]
|
btnClick(): void{
var rule = this.qryBldrObj.getValidRules();
let ajax: XMLHttpRequest = new
XMLHttpRequest();
ajax.open('POST',
'https://localhost:7255/querybuilder/GetValidRules', true);
ajax.setRequestHeader('Content-Type',
'application/json');
ajax.onreadystatechange =
function () {
if (ajax.readyState ===
XMLHttpRequest.DONE) {
if (ajax.status === 200)
{
var dt =
ajax.responseText;
// Handle the
successful response here
} else {
// Handle the error,
e.g., display an error message
console.error('Error:', ajax.status, ajax.statusText);
}
}
};
// Convert the data to JSON
string before sending
ajax.send(JSON.stringify(rule));
}
|
Sample link: https://stackblitz.com/edit/angular-9qnbcb-5rnqw7?file=src%2Fapp.component.ts
[Server]
|
public
void GetValidRules(dynamic data)
{
var jsonString =
JsonConvert.SerializeObject(data);
Rule actualRuleSet =
JsonConvert.DeserializeObject<Rule>(jsonString);
bool isRulesProperlyFramed =
AreRulesProperlyFramed(actualRuleSet);
}
|
Please let us know if you need any further
assistance on this.
Regards,
KeerthiKaran K V
Attachment:
WebService_7ac01946.zip