Announcement

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

    Using Canvas.provideRuleScope property

    Hello Isomorphic
    I have a filter form that has selected values for context that I would like to be able to access in a window modal DynamicForm.
    The search form does not fall into the default ruleScope and it seems that I can add this form using the Canvas.provideRuleScope property but cannot figure out how to use it and cannot find any forum posts or any other mention of its usage other than this :
    https://www.smartclient.com/smartcli...ideRuleContext

    Here is the simlified XML component definition I have:
    [HTML]<SearchForm ID="SrchFrm123"><fields><field name="bling"/></fields><SearchForm>
    <ListGrid><...></ListGrid>
    <Window><DynamicForm ID="CrudFrm678"><fields><field name="blah">...</fields></DynamicForm></Window>[/HTML]

    I would like to add a dynamc optionCriteria to field "blah" that fetches the value of field "bling" using the optionCriteria like this:
    [HTML]<field name="blah" title="My Field" type="select" autoFetchData="false" editorType="ComboBoxItem" displayField="blah_name" valueField="id" optionDataSource="S9d7c4fd038_ds" ><optionCriteria><fieldName>"bling"</fieldName><operator>"equals"</operator><valuePath>"SrchFrm123.values.bling"</valuePath></optionCriteria>[/HTML]

    Is it possible to use provideRuleScope attribute to make the SrchFrm123 form accessible from the CrudFrm678 DynamicForm?

    Help would be very much appreciated.
    Last edited by chris@umed.io; 15th Sep 2020, 15:29.

    #2
    Any DynamicForm will provide it's values to the ruleScope under it's ID, so it's already in the ruleScope in pretty much the format you're expecting, however, you are quoting the values for valuePath etc which is incorrect.

    Comment


      #3
      Thanks for the reply - my bad - I transcribed the example with quotes but in the actual implementation it does not have quotes.
      The reason I am focussed on the provideRuleScope (or provideRuleContext if that is better) property is because if I change the "valuePath" attribute value to the same DynamicForm the field containing the dynamic optionCriteria is, then it correctly retrieves a value and passes it in the "criteria" part of the request to the server as expected.
      eg.
      [HTML]<optionCriteria><fieldName>blah</fieldName><operator>equals</operator><valuePath>CrudFrm678.values.field_in_same_form_as_blah_field</valuePath></optionCriteria>[/HTML]

      Because this works, I am operating under the possibly incorrect assumption that the "SrchFrm123" form is not within the scope of the "CrudFrm678" form.

      Reading the spec on ruleScope my understanding is that if no ID field is set then it uses the parentCanvas chain to determine the accessibility of other data which if I have understood it correctly means the <Window> element containing the "SrchFrm123" form is not within the scope of the "CrudFrm678" form parentCanvas chain.

      I have tried setting "ruleScope" attribute on the "CrudFrm678" to:
      ruleScope="SrchFrm123"
      ... but that has not made any difference.

      NOTE: I have verified before the <Window> element is instantiated and the datasource call is made for the "blah" field that in the browser console running "SrchFrm123.values.bling" returns the expected value that should be passed in the criteria request param construct for the "blah" field datasource request.

      This is using "v12.1p_2020-06-06/Pro"
      Last edited by chris@umed.io; Yesterday, 04:56.

      Comment


        #4
        Did you notice the API getRuleContext()? You don't have to speculate about whether data is present or not, you can just look. The echoFull() method is a good way to get a quick JSON dump.

        It's true that if you have two different top-level hierarchies, like a Window that isn't contained within the same top-level parent as other components, those are separate ruleScopes. If you are having trouble unifying them via the canvas.ruleScope property, please show us the actual code, as a minimal, ready-to-run test case, and we can take a look and either correct your usage or fix a bug if one is revealed.

        Comment

        Working...
        X