6 Replies Latest reply on Jul 13, 2016 9:55 AM by supandey RSS
    tcoufal Communicator

    Default Query for dataFilter widget

    Hi Guys,

    I have following (maybe dumm) question.

    I am using a DataFilter widget I can see that query property is bindable in both directions. I would like to create sort of "default query" for my queryService which would persist.

    I have assigned query from DataFilter widget and added one filter to query inside service parameter directly. That one does not seem to take any effect.

     

    How to create a default query for DataFilter widget. I was thinking about to create a property(ies) inside some thing which would hold the queries, but its not as flexible as I would like to be.

     

    Any ideas?

      • Re: Default Query for dataFilter widget
        supandey Collaborator

        Hi Tomas,

         

        I'm not sure if this is what you mean, but query definition could be held within the QueryService itself e.g.:

         

        var query = {

          "filters": {

            "type": "AND",

            "filters": [

              {

                "fieldName": "STATE",

                "type": "LIKE",

                "value": "*"

              },

              {

                "fieldName": "ZIPCODE",

                "type": "NE",

                "value": 0

              }

            ]

          }

        };

         

        var params = {

          query: query /* QUERY */,

        };

         

         

        // result: INFOTABLE dataShape: RootEntityList

        var result = ThingTemplates["Database"].QueryImplementingThingsWithData(params);

         

        Additionally, just a minor mention that Query can also be formulated directly in the service by Editing the Query value which would work as a default Query

         

         

        And probably when using the Configure Widget for the DataFilter Binding Source could be defined for the Query Property, acting as a default query.

          • Re: Default Query for dataFilter widget
            tcoufal Communicator

            Hi Sushant,

             

            not quite.. I dont know what you mean "can be held inside the query service itself", I know that you can edit the Query in mashup (pic above). Problem is that DataFilter widget's query is bound to service query parameter, but at the beginning that widget query is empty because nothing is bound to it in opposite direction (and I cannot use Query paramater as input parameter for that widget), thus reseting the service's query parameter.

             

            On different subject,

            It seems that DataFilter widget does only AND between different filters. Is there any way how to do OR?

             

            Thanks

          • Re: Default Query for dataFilter widget
            supandey Collaborator

            Hi Tomas, I'm gonna see if i can find any other more meaningful option for your default query. In the meantime may be someone else might have a quick idea on this could help.

             

            With holding query i was only mentioning about the queries definition which is kept in the

            var params = {

              query: query /* QUERY */,

            };

             

            Anyway, I suppose this isn't helping your cause.

             

             

            To answer your other question, as a matter of fact you can use OR -  Queries allow you to use AND / OR, may be you want have a look at the Query documentation with all possible combinations.

             

            Hope this helps.

              • Re: Default Query for dataFilter widget
                tcoufal Communicator

                To answer your other question, as a matter of fact you can use OR -  Queries allow you to use AND / OR, may be you want have a look at the Query documentation with all possible combinations.

                 

                Yes, but current DataFilter does not include this option, or does it?

                 

                U suppose I can follow Ngo's proposal, to create a service which will validate the query made by DataFilter widget, and it will set AND to OR depending on some other widget's state (list, radio button etc.). Not very flexible and elegant, but certainly valid option (or am I mistaken?)


                Tomas

                  • Re: Default Query for dataFilter widget
                    supandey Collaborator

                    You're right within the Data Filter Widget I haven't seen this option. When using Data Filter Widget personally if i need a search which need OR, in that case i use the filter option "Contains" instead of exact match for the Strings and for numeric values i go for greater than or less then operator to get larger result set. Indeed this method is not sophisticated either but allows me to workaround for not having "OR".

                     

                    It does sound like a genuine workaround for me, so you could give it a try esp. if it help gets you going with your project.

                     

                    In any case i am keeping my eyes open for further info/update concerning your important questions and will update this thread should there be any.

                • Re: Default Query for dataFilter widget
                  qngo Creator

                  In order to combine and personalize the query used by the DataFilter widget, I used a service (QueryProcess, for example) to parse its query (a json) and to recreate my filter by combining with other criteria. So I think that you can bind the DataFilter widget's query property to this service QueryProcess. If the query is empty, the service can return a "default" query which is bind to your final service.