Announcement

Collapse
No announcement yet.

issue with sc_field_init_off

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

  • issue with sc_field_init_off

    Hello there,

    I am having issues with the sc_field_init_off macro. I am storing the names of which fields a user wants to see in a db table and then trying to by user display their preferred fields. So...

    $list2 = {field1}, {field2}, {field3}
    sc_field_init_off($list2);

    This won't work. However this works...

    sc_field_init_off({field1}, {field2}, {field3});

    Any idea as to why this wouldn't work or how I might do it different?

    Thanks in advance.

  • #2
    Hello,

    That is actually the default behavior of the macro.

    regards,
    Bernhard Bernsmann

    Comment


    • #3
      Thanks for the reply Bernhard. Why is this the case and is there an alternative way that you can think of to have users show the grid with their default choices? I have modified the select clauses in the core sql based on user supplied preference, but this limits the functionality quite a bit. I love this macro but for the life of me I cannot figure out why it was limited to not feed the field list dynamically.

      Comment


      • #4
        Hello,

        It doesn't work because it works just as a PHP function. Take explode as an example:

        //this works
        $pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
        $pieces = explode(" ", $pizza);

        You cannot pass a variable as both parameters, as below:

        $param = " , piece1 piece2 piece3 piece4 piece5 piece6"; (or pass the " " as well using escape strings)
        $pieces = explode($param);

        The alternative would be to hardcode sc_field_init_off.. Or instead use sc_field_display to show their preferred fields

        if (someLogic)
        sc_field_display({field1}, on);
        if (someOtherLogic
        sc_field_display({field2}, on);

        Comment


        • #5
          Thanks for the further explanation. I will play with it more tomorrow to get a better understanding. I did end up using sc_field_display, but now we have three buttons in the toolbar to control what and how the content is viewed in the grid. This does seem excessive. I might suggest that much like saved searches in grids we have the option to save the column selections including which columns show, in what order and what the sort order is into a search mode / Save Criteria like mechanism. Speaking of Save Criteria, I would also suggest that these be accessible to the gird display in the toolbar and not be available only in search mode.

          Comment

          Working...
          X