Announcement

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

    12.0p: How to use JSONEncoder in showcase?

    Hi Isomorphic,

    can you show to to use your JSONEncoder clientside?

    Creating another testcase, I tried this here (v12.0p_2018-12-13) and did not succeed:
    Code:
    isc.JSONEncoder.create({
        ID:"encoder"
    });
    
    isc.ListGrid.create({
        ID:"dsListGrid", 
        width: "100%",
        height: "100%",
        autoFetchData: false,
        canEdit: true,
        initialSort: [
            {property: "category", direction: "ascending"},
            {property: "units", direction: "ascending"}
        ],
        dataSource: "supplyItem",
        showFilterEditor: true,
        implicitCriteria: { fieldName: "units", operator: "isNull" },
    });
    
    isc.IButton.create({
        ID:"fetchButton", width: 200,
        title:"Fetch no criteria",
        click : function () {
            dsListGrid.fetchData();
        }
    });
    
    isc.IButton.create({
        ID:"fetchFilteredButton", width: 200,
        title:"units criteria fetchData()",
        click : function () {
            dsListGrid.fetchData({ _constructor: "AdvancedCriteria", fieldName: "units", operator: "equals", value: "Ea"});
        }
    });
    
    isc.IButton.create({
        ID:"showImplicitCriteria", width: 200,
        title:"Show ImplicitCriteria",
        click : function () {
            isc.say(encoder.encode(dsListGrid.getImplicitCriteria()))
        }
    });
    
    isc.HStack.create({
        ID:"hStack",
        membersMargin:10,
        members:[ fetchButton, fetchFilteredButton, showImplicitCriteria]
    });
    
    isc.VLayout.create({
        membersMargin:10,
        width: "100%",
        height: "100%",
        members:[ dsListGrid, hStack]
    });
    Error in the developer console on click of "Show ImplicitCriteria" is:
    Code:
    13:50:15.299:MUP1:WARN:Log:ReferenceError: encoder is not defined
    Stack from error.stack:
        _3.click(<no args: exited>) on [IButton ID:showImplicitCriteria] @ [no file]:158:17
        StatefulCanvas.handleActivate(<no args: exited>) on [IButton ID:showImplicitCriteria] @ ISC_Foundation.js:236:108
        StatefulCanvas.handleClick(<no args: exited>) on [IButton ID:showImplicitCriteria] @ ISC_Foundation.js:237:13
        [c]EventHandler.bubbleEvent(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:2146:89
        [c]EventHandler.handleClick(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:1980:50
        EventHandler._handleMouseUp(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:1964:11
        [c]EventHandler.handleMouseUp(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:1955:57
        [c]EventHandler.dispatch(_1=>[c]EventHandler.handleMouseUp(), _2=>[object MouseEvent]) on [Class EventHandler] @ ISC_Core.js:2233:108
        HTMLDocument.eval(event=>[object MouseEvent]) @ [no file]:3:123
    Thank you & Best regards
    Blama

    #2
    You can either do var encoder = isc.JSON.... etc, or you can access window.encoder instead.

    Comment


      #3
      Hi Isomorphic,

      this code works as expected:
      Code:
      isc.IButton.create({
          ID:"showImplicitCriteria", width: 200,
          title:"Show ImplicitCriteria",
          click : function () {
              isc.say(isc.JSON.encode(dsListGrid.getImplicitCriteria()))
          }
      });
      Thanks a lot,
      Blama

      Comment

      Working...
      X