Announcement

Collapse
No announcement yet.

adding custom search criteria?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • adding custom search criteria?

    In the grid-search section it is possible to add custom fields. These are shown in the search form before applying the search on the grid. My problem is that there's no event where I can intercept the search to apply the extra criterium to. There's an onscriptinit, onsave, onvalidate. But the macro to add sql doesn't work, and using global variables doestn't work. Somehow none of the event in the search are triggered.

    Is there anybody who has applied a custom field search and can descript how I can get this running?
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

  • #2
    Just to clarify... you want it to search in all fields listed in the grid?... or in the ones selected by the search configuration?.

    Regards

    P.S.- one more thinkg do you want it to filter the records or just to possition yourself in the nearest record that matches the criteria?
    Last edited by kafecadm; 04-22-2015, 08:03 PM.

    Comment


    • #3
      Originally posted by kafecadm View Post
      Just to clarify... you want it to search in all fields listed in the grid?... or in the ones selected by the search configuration?.

      Regards

      P.S.- one more thinkg do you want it to filter the records or just to possition yourself in the nearest record that matches the criteria?
      No, if you click the search button then you get the search form. Your custom field is on it. But there's no way you can use this custom field to influence the generated sql, so in the current situation it is useless. I tried macro's and (global) variables but nothing works. The events which are at the search section don't seen to work either.
      Albert Drent
      aducom software netherlands
      scriptcase partner, reseller, support and (turn-key) development
      www.scriptcase.eu / www.scriptcase.nl

      Comment


      • #4
        Ok.. I did something but with a blank application and global variable for a personalized quicksearch in a grid.

        in the grid i created the sql statement as:

        PHP Code:
        select *
        from  table
        where 
        [g_Condition
        Where g_Condition is initialized to 1 in case it comes blank in the onapplicationinit I also created another global called g_Iframe and i initialized it with something like:

        PHP Code:
        $link sc_make_link(QuickSearch); //quicksearch is the name of my blank app
        [g_Iframe]= '<iframe src="' $link '"></iframe>'
        in the header of the grid called the variable g_Iframe calling into one of the td's the control application:

        Regarding the control application i removed the toolbar, the header and footer and created a single field and as you might figured by now that field has an ajax event onchange.

        PHP Code:
        $condition"Field1 ='" . {search} . "'  or Field2 = '" . {search} . "'";
        sc_reditGridApplicationg_Condition=$condition_parent); 
        I have way more code in here but this is the basic idea.
        Hope this helps

        Regards

        Comment


        • #5
          Tnx for reply. I get the idea, but it's not what I am looking for unfortunately. I need to add a select part on a custom search field. I need to select on workday while the database only has dates. It's not difficult in MySQL terms, but I cannot build this within a search screen. I worked around by using a separate filter application, but that's what it is, a work-around.
          Albert Drent
          aducom software netherlands
          scriptcase partner, reseller, support and (turn-key) development
          www.scriptcase.eu / www.scriptcase.nl

          Comment


          • #6
            Well my b.

            Regards.

            Comment


            • #7
              Yes, appreciated!
              Albert Drent
              aducom software netherlands
              scriptcase partner, reseller, support and (turn-key) development
              www.scriptcase.eu / www.scriptcase.nl

              Comment


              • #8
                I am trying to do the exact same thing and also cannot figure out where to put the SQL SELECT statement for the custom field.

                Comment


                • #9
                  Agree, some news/workaround about this?

                  I have a field, and depends on it's value on search form, I want to modify the SQL criteria.
                  Example:
                  I have a field 'facturado' with a value NULL or an ID, but in search, I want to show as a checkbox. If Yes, I want to filter but facturado>0, If not, "facturado is null"
                  /Giuseppe

                  Professional Scriptcase Services
                  Some Customers opinions

                  Comment


                  • #10
                    @giu

                    if you can create a sql view, it's easy.
                    create a sql view with a new "facturado_sc_searchahble" field and, using a sql IF statement, set it to the values you can work on in the sc search form.

                    Comment


                    • #11
                      Originally posted by robydago View Post
                      @giu

                      if you can create a sql view, it's easy.
                      create a sql view with a new "facturado_sc_searchahble" field and, using a sql IF statement, set it to the values you can work on in the sc search form.
                      I know, but I would like to know if it's possible using SC features. It's very interesting (and needed) to modify Search criteria by code
                      /Giuseppe

                      Professional Scriptcase Services
                      Some Customers opinions

                      Comment


                      • #12
                        Hi Albert!!!!!
                        My friend! Sorry I haven't skyped in like forever. I will try you later this week.

                        I know this is a year old post - but I figured out something just today on same thing. You and I always seem to be trying the same things LOL.

                        On a grid app I am using aes_encryption , so I am not able to directly use the advanced search (or any search) for those fields. (I use AES_DECRYPT in the SQL Select and preparation boxes and other events to do it FYI, but that is another post LOL).

                        So I also needed to create some 'fake' fields in the advanced search, and intercept the values, then slip those in the special WHERE using the AES_DECRYPT). Yes unfortunately , the macros in thr search events do not seem to add anything to WHERE, so this is what I did (SC bug???).

                        In the grid's event onScriptInit (NOT the search onScriptInit) - searchname and searchaddress are 'fake' fields I created in advanced search...No corresponding fields in DB. (I had to do this because the encryption SQL code that works elsewhere in the app caused errors in search code. The title_search is a global OUT I use in the layout header. I added the code below:

                        if ( empty({searchname}) AND empty({searchaddress}) )
                        {
                        [title_search] = "";
                        }
                        else
                        {
                        [title_search] = "Name contains '".{searchname}." AND Address contains '".{searchaddress};

                        sc_select_where(add) = " AND CONVERT(AES_DECRYPT(`first_name`, @aeskey) USING utf8) LIKE '%".{searchname}."%' AND CONVERT(AES_DECRYPT(`address`, @aeskey) USING utf8) LIKE '%".{searchaddress}."%'";
                        }



                        When the app loads the 2 fake search fields are empty by default. When I click advanced search button, I can put anything I want in those fields. Then the grid processes the search, which really does nothing as far the 'fake' fields are concerned. It is when the onScriptInit for the whole app (NOT the search onScriptInit) that the values are added to the WHERE.

                        This is working for me. So far so good.

                        Peace everyone,
                        Jamie

                        Comment


                        • #13
                          Scriptcase has made progress a lot last year. I had a work-around which is working well at my client and never change a working app is my motto ;-)
                          So I haven't been looking into this issue a long time,but I will of course once I run into a similar situation. Thanks for your report.
                          Good to hear you're still alive ;-)
                          Albert Drent
                          aducom software netherlands
                          scriptcase partner, reseller, support and (turn-key) development
                          www.scriptcase.eu / www.scriptcase.nl

                          Comment

                          Working...
                          X