Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #102589
    TurricanDE
    Participant
    Up
    0
    Down

    Is there an easy way to get the filter phrase like “contains Andrew or contains Nancy” from this event like what is described in the Javascript Grid API?

    ev.detail.data

    – Array of {dataField: string, filter: string}.

    dataField is the column’s data field.

    filter is a filter expression like ‘startsWith B’

    In Blazor I have the following Event-Handler:

    private async Task OnFilter(Event ev)
    {
    GridFilterEventDetail filterEventDetail = ev[“Detail”];

    => What’s next here =?  I want to know the name of the dataField and the filter value (“contains Andrew or contains Nancy”)

    }

     

     

    • This topic was modified 1 week, 3 days ago by TurricanDE.
    #102591
    Yavor Dashev
    Participant
    Up
    0
    Down

    Hi TurricanDE,

    I have prepared a quick code snippet on how to achieve the functionality that you need.

        private void filterEvent(Event ev)
            {
                GridFilterEventDetail filterEventDetail = ev["Detail"];
    
                Console.WriteLine(filterEventDetail.Data[0].filter.filters[0]);
                Console.WriteLine(filterEventDetail.Data[0].dataField);
            }
    

    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/

    #102592
    TurricanDE
    Participant
    Up
    0
    Down

    Hello Yavor,

    Thank you for the example.

    filterEventDetail.Data[0].dataField is exactly what I needed, but

    filterEventDetail.Data[0].filter.filters[0] gives me an Object and not the filter phrase as a string.

    In the debugger I can’t see how to get easily the filter string from this Object.

    Any advice?

    #102595
    Yavor Dashev
    Participant
    Up
    0
    Down

    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/

    #102602
    TurricanDE
    Participant
    Up
    0
    Down

    Hello Yavor,

    Thank you so much for the example. It is the right direction

    But the example will only work for “contains <sometext>” when you set the filter programmatically. For example “does_not_contains <sometext>” and the others string conditions doesn’ work ( I guess the filter conditions must have other names).

    I found in the Grid API documentation the supported filter conditions :

    https://www.htmlelements.com/docs/grid-filtering-sorting/

    But I’ve tried to set the condition like “notcontains <sometext>” but the filter panel shows me “startsWith” ?

    When I set the filter condition like “startswith <sometext>” the filter panel shows me “equal”?

    What I am doing wrong?

     

     

    #102606
    Yavor Dashev
    Participant
    Up
    0
    Down

    Hi TurricanDE,

    It’s my fault for the wrong behavior, because the default filters for the SmartGrid others and the ones that I shared are all the filters available for the SmartGrid.

    This is how the filter conditions list should be in order to get the right results:

     List<string> stringConditions = new List<string> (){  
                    "EMPTY",
                    "NOT_EMPTY",
                    "CONTAINS",
                    "DOES_NOT_CONTAIN",
                    "STARTS_WITH",
                    "ENDS_WITH",
                    "EQUAL",
                    "NOT_EQUAL",
                    "NULL",
                    "NOT_NULL"
                  };

    Let me know if this works for you!

    Please, do not hesitate to contact us if you have any additional questions.

    Best regards,
    Yavor Dashev

    Smart UI Team
    https://www.htmlelements.com/

    #102614
    TurricanDE
    Participant
    Up
    0
    Down

    Hello Yavor,

    Yes I’ve seen this before, I already set the string conditions like you suggested.

    But when I collect the filter string in the Event then the string looks like

    “CONTAINS abc” or “DOES_NOT_CONTAIN abc” and so on…

    But what has the filter string exactly looks like for every condition if we set this collected filter string programmatically somewhere else?

    It works when I set “contains abc”.

    But not if I set “does_not_contain abc” etc. (I user lower case)

    The hamburger menu is gone and the grid didn’t respond anymore.

    I use the Grid Filtering.Filter property like this:

    List<IEnumerable<string>> Filter = new List<IEnumerable<string>>()
    {
    new List<string> { “FirstName”, “contains Andrew” } // => works

    };

    or

    List<IEnumerable<string>> Filter = new List<IEnumerable<string>>()
    {
    new List<string> { “FirstName”, “does_not_contain Andrew” } // => doesn’t work
    };

    MyGrid.Filtering.Filter = filter

    I thought the conditions have to be like as in the documentation:

    https://www.htmlelements.com/docs/grid-filtering-sorting/

    I tried this:

    List<IEnumerable<string>> Filter = new List<IEnumerable<string>>()
    {
    new List<string> { “FirstName”, “startswith Paul” }

    // => the filter is working, but the filter column panel shows me “equal” instead of “starts with” for   the first condition
    };

     

     

     

    • This reply was modified 2 days, 7 hours ago by TurricanDE.
    • This reply was modified 2 days, 7 hours ago by TurricanDE.
    #102617
    Yavor Dashev
    Participant
    Up
    0
    Down

    Hi TurricanDE,

    When you want to apply the ‘DOES_NOT_CONTAIN’ filter you have to use it like in the following code snippet:

       GridFiltering filtering = new GridFiltering()
        {
            Enabled = true,
            Filter = new string[][]
            {
                new string[] { "FirstName", "notcontains Andrew" }      
            }
         
        };

    As for the filter panel this behavior is not expected and I will add a work item for this use case.

    Please, do not hesitate to contact us if you have any additional questions.

    Best regards,
    Yavor Dashev

    Smart UI Team
    https://www.htmlelements.com/

    #102619
    TurricanDE
    Participant
    Up
    0
    Down

    Hello Yavor,

    Thank you for your reply.

    Where can I find all other phrases it seems the documentation is outdated?

    “notcontains” “startswith” and so on…

    Another problem I ran into:

    I use often to change dynamically a column set in the grid. Let’s say I have 3 different sets:

    Set 1 : Column A (with a “contains” filter), Column B, Column C
    Set 2: Column A, Column B (with a “contains” filter), Column C, Column D
    Set 3: Column A, Column B, Column C, Column D, Column E (no filters are set in any column)

    They more I switch between a set with a filter, they more this slows down the grid (every switch is +1 sec slower or so) , a switch to a column set without a filter is immediatley responsive.

    I use the Grid.ClearFilter() method before I set the next columns.

     

     

    #102620
    admin
    Keymaster
    Up
    0
    Down

    Hi,

    Actually, the docs were updated yesterday with 11.0 release, but these strings are not added to the API and we will add it. However, we have a help topic about filtering and you can find it here: https://www.htmlelements.com/docs/grid-filtering-sorting/

    Best Regards,
    Peter Stoev

    Smart UI Team
    https://www.htmlelements.com/

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.