Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    javascript in ds.xml

    I seem to remember seeing a way to embed javascript in the data source ds.xml files but can't seem to find it any longer. In my particular case, I have a field that I would like to set a ShowIfCondition on. But rather than do that in code I want to put the condition in the ds.xml file itself. I'm using a reusable component with the data source and don't want to have to put custom code in it to deal with this field. The ShowIfCondition is pretty simple. In SmartGWT code I would do something like
    Code:
    FormItem fi = new FormItem();
    fi.setShowIfCondition(new FormItemIfFunction() {
    
      @Override
      public boolean execute(FormItem item, Object value, DynamicForm form)   
      {
        return IPGui.isFinanceSystemInstalled;
      }
    
    });
    Can I put the same sort of thing in the datasource.ds.xml file.

    #2
    You can put JavaScript expressions for showIf into the DataSource XML file, but not Java. It doesn't go through the GWT compiler.

    Comment


      #3
      Thanks. But how? Can you provide an example of a ds.xml that has a simple showIf condition?

      Comment


        #4
        Code:
        <field name="discount" showIf="values.quantity > 4"/>
        Just to clarify, it's a bit of a hack to do this in SGWT, and you'd basically be referring to the SmartClient Reference for what's available to you in the showIf expression.

        Comment


          #5
          Is there a better way to do it in SGWT? Since I'm using a generic UI component and just passing it a different datasource each time, I'm trying to avoid coding something specific for this one field.

          Comment


            #6
            Subclass the UI components in question and make it aware of this field's special behavior.

            Comment


              #7
              Originally posted by Isomorphic
              Code:
              <field name="discount" showIf="values.quantity > 4"/>
              Just to clarify, it's a bit of a hack to do this in SGWT, and you'd basically be referring to the SmartClient Reference for what's available to you in the showIf expression.
              I am trying to do this (ie. selectively hide some fields in a form), but I get "(ReferenceError): values is not defined" when binding the same DataSource to a ListGrid.

              This (kind of) makes sense, since according to the SmartClient Reference, ListGrid.showIf does not have a 'values' parameter; only formItem.showIf has it.

              Is there a way apply a showIf condition that only applies for DynamicForms, but does not apply to ListGrids?

              Thank you for your help:

              Csillag

              Comment


                #8
                Originally posted by csillag
                Is there a way apply a showIf condition that only applies for DynamicForms, but does not apply to ListGrids?
                For now, I just started using a new attribute "formShowIf", add when I find one of these on the client side (in my subclass of DynamicForm), I automatically apply it to the form items.

                So it works all right now.

                Comment

                Working...
                X