Announcement

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

    provideRuleContext problem

    SmartClient Version: v11.0p_2016-03-30/EVAL Development Only (expires 2016.05.29_20.49.40) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

    Chrome on OSX

    Hello, I'm trying to use the provideRuleContext method, to understand it better, but I think I've found a bug.

    I'm running this code (in the showcase):

    Code:
    isc.ListGrid.create({
        ID: "testList",
        width:500, height:224, alternateRecordStyles:true,
        dataSource: countryDS,
        buttonEnabled:false,
        fields:[
            {name:"countryName"},
            {name:"continent"},
            {name:"member_g8"},
            {name:"population"},
            {name:"independence"}
        ],
        autoFetchData: true,
        canEdit: true,
        listEndEditAction: "next",
        autoSaveEdits: false
    })
    
    isc.IButton.create({
        ID:"testButton",
        top:250,
        title:"Edit New",
        enableWhen:{_constructor:"AdvancedCriteria",operator:"and",
        criteria:[
          {fieldName:"testList.buttonEnabled", operator:"equals", value:true}
        ]},
        click:"countryList1.startEditingNew()"
    })
    testButton is correctly disabled, then if I execute:
    Code:
    testButton.provideRuleContext ("testList.buttonEnabled", true);
    it correctly become enabled, and if I execute:
    Code:
    testButton.provideRuleContext ("testList.buttonEnabled", false);
    it become disabled and so on.

    But if I interact with the grid, then the button stops reacting to the provideRuleContext call.

    Is it a bug or am I totally misusing this method? Actually would be nice to have a sample in the showcase.

    #2
    If you are trying to provide your own additional rule context, you should not be providing it under the prefix "testList" since the grid has that ID and will already be publishing data under that prefix, which will clobber whatever you are providing.

    Comment


      #3
      Ok, so I must call it like this:
      Code:
      testButton.provideRuleContext ("buttonEnabled", true, testList); /*3rd parameter is not necessary*/
      And actually I see the 'buttonEnabled' value if I call testList.getRuleContext()

      But now the testButton remains always disabled... :(

      Comment


        #4
        Perhaps too obvious, but have you updated your criteria so that it now refers to the new ruleContext you're providing? Because if the criteria still refers to the old name of testList.buttonEnabled, it would be expected that the button remains permanently disabled.

        Comment


          #5
          Hello, I'm using this test case:

          Code:
          isc.ListGrid.create({
              ID: "testList",
              width:500, height:224, alternateRecordStyles:true,
              dataSource: countryDS,
              fields:[
                  {name:"countryName"},
                  {name:"continent"},
                  {name:"member_g8"},
                  {name:"population"},
                  {name:"independence"}
              ],
              autoFetchData: true,
              canEdit: true,
              listEndEditAction: "next",
              autoSaveEdits: false
          })
          
          isc.IButton.create({
              ID:"testButton",
              top:250,
              title:"Edit New",
              enableWhen:{_constructor:"AdvancedCriteria",operator:"and",
              criteria:[
                {fieldName:"testButton.buttonEnabled", operator:"equals", value:true}
              ]},
              click:"countryList1.startEditingNew()"
          })
          
          isc.IButton.create({
              ID:"enableButton",
              top:280,
              title:"Enable",
              click:"testButton.provideRuleContext ('buttonEnabled', true, testList);"
          })
          
          isc.IButton.create({
              ID:"disableButton",
              top:310,
              title:"Disable",
              click:"testButton.provideRuleContext ('buttonEnabled', false, testList);"
          })
          but actually, no, it's not too obvious for me, because my understanding of the topic is rather rough, for now.

          Comment


            #6
            Your criteria still don't agree with the ruleContext you are providing. One is just buttonEnabled and the other testButton.buttonEnabled.

            Comment


              #7
              ok, so this is working:
              Code:
              isc.ListGrid.create({
                  ID: "testList",
                  width:500, height:224, alternateRecordStyles:true,
                  dataSource: countryDS,
                  fields:[
                      {name:"countryName"},
                      {name:"continent"},
                      {name:"member_g8"},
                      {name:"population"},
                      {name:"independence"}
                  ],
                  autoFetchData: true,
                  canEdit: true,
                  listEndEditAction: "next",
                  autoSaveEdits: false
              })
              
              isc.IButton.create({
                  ID:"testButton",
                  top:250,
                  title:"Edit New",
                  enableWhen:{_constructor:"AdvancedCriteria",operator:"and",
                  criteria:[
                    {fieldName:"testButton.buttonEnabled", operator:"equals", value:true}
                  ]},
                  click:"testList.startEditingNew()"
              })
              
              isc.IButton.create({
                  ID:"enableButton",
                  top:280,
                  title:"Enable",
                  click:"testButton.provideRuleContext ('testButton.buttonEnabled', true);"
              })
              
              isc.IButton.create({
                  ID:"disableButton",
                  top:310,
                  title:"Disable",
                  click:"testButton.provideRuleContext ('testButton.buttonEnabled', false);"
              })
              ​thanks for your guidance. Btw it's really a powerful feature!

              Comment

              Working...
              X