Announcement

Collapse
No announcement yet.

Any way to set up default Filter on a Grid?

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

  • Any way to set up default Filter on a Grid?

    For example lets say I have a orders database with orders in different states.
    In process
    Waiting parts
    Shipped
    In Shipping etc..

    You get the idea.

    Now when the grid of orders opens I want to view only orders that are in process as default, I can do this with a Where in the SQL but I might want to look at orders that are waiting parts at some point or the ones that are in shipping and the where clause excludes those from loading.

    I know I can add a dynamic search to the grid and limit it that way but if possible I don't want to do a search to start I would rather be able to see the default and look at those and then only search if I want to see the others.

    Any ideas?

  • #2
    one way might be to use a global variable in your where clause like

    where [myselect];

    In the onscriptinit you can set [myselect]='myargument = "something"';

    this will set the sql statement initially. If you define a button to 'reset' the 'where' you are able to use the advanced search.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      You can use:

      Code:
      sc_apl_conf("my_grid", "start", "filter");
      Note: I believe though that this needs to be set in a different application than the one it is to apply too - usually from the menu app, but can be anywhere.

      Comment


      • #4
        Albert @aducom
        How would I define a button to 'reset' the where?
        Thanks.

        Comment


        • #5
          First set the default argument of [myselect] in the menu execute event which calls your application.
          Next create a button of type php called 'reset'. In the phpcode you set [myselect]='1=1'; // needed because else you would have an empty where clause
          Then do a sc_exit(sel); to load the same application again. You need to move the initial value outside of the application as onapplicationinit will fire again. Other option is to set the global in the onapplicationinit which is fired only once.
          Albert Drent
          aducom software netherlands
          scriptcase partner, reseller, support and (turn-key) development
          www.scriptcase.eu / www.scriptcase.nl

          Comment

          Working...
          X