JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Data Grid › OnFilter Event (Blazor) › Reply To: OnFilter Event (Blazor)
November 26, 2021 at 4:26 pm
#102595
Yavor Dashev
Participant
Hi TurricanDE,
I have created another code snippet as a workaround to showcase you how to get the filter string from the Grid component
List<string> stringConditions = new List<string> (){
"EMPTY",
"NOT_EMPTY",
"CONTAINS",
"CONTAINS_CASE_SENSITIVE",
"DOES_NOT_CONTAIN",
"DOES_NOT_CONTAIN_CASE_SENSITIVE",
"STARTS_WITH",
"STARTS_WITH_CASE_SENSITIVE",
"ENDS_WITH",
"ENDS_WITH_CASE_SENSITIVE",
"EQUAL",
"NOT_EQUAL",
"EQUAL_CASE_SENSITIVE",
"NOT_EQUAL_CASE_SENSITIVE",
"NULL",
"NOT_NULL"
};
private void filterEvent(Event ev)
{
GridFilterEventDetail filterEventDetail = ev["Detail"];
string logicalOperator= "";
if(filterEventDetail.Columns[0]["_filterState"]["logicalOperator"] == -1 )
{
logicalOperator = "and";
}
else {
logicalOperator = "or";
}
int firstFilterComparison = filterEventDetail.Columns[0]["_filterState"]["firstFilterComparison"];
string firstFilterValue = filterEventDetail.Columns[0]["_filterState"]["firstFilterValue"];
int secondFiltercomparison= filterEventDetail.Columns[0]["_filterState"]["secondFilterComparison"];
string secondFilterValue= filterEventDetail.Columns[0]["_filterState"]["secondFilterValue"];
Console.WriteLine(stringConditions[firstFilterComparison] + " " + firstFilterValue+ " "+ logicalOperator+ " " + stringConditions[secondFiltercomparison] + " " + secondFilterValue);
}
Let me know what you think!
Please, do not hesitate to contact us if you have any additional questions.
Best regards,
Yavor Dashev
Smart UI Team
https://www.htmlelements.com/