Announcement

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

    ListGrid, saveLocally & dataPath

    Hello,

    I know the data path API is still in development but I think I've found an issue with it (not sure if its already known). I'm using the build 2011-06-08/LGPL.

    Basically I have 2 ListGrids with a datapath and saveLocally set to true. The reason I use saveLocally is because I don't want changes in the ListGrid to trigger a datasource Create or Update operation.

    This was working fine until I tried some drag and drop behaviour. Dragging a record from one ListGrid to another (with dragDataAction set to the default 'move') triggers an 'update' operation on my DataSource which I was not expecting.

    Changing the dragDataAction to 'copy' or 'none' doesn't trigger an update operation but it isn't the behaviour I'm looking for (I do want to move the data locally without triggering any datasource operation).

    If required I should be able to put together a straight-forward test-case for you.
    Last edited by jaredm; 12 Jun 2011, 03:07.

    #2
    Can you confirm that you meant to say that you've set saveLocally to TRUE, not false? saveLocally: true is what you need if you want to avoid operations running automatically.

    If that's what you're doing and you think there's still a bug then, yes, please provide a test-case and we'll take a look.

    Comment


      #3
      Hello,

      You are correct, I meant to say I use saveLocally set to 'true'. I've corrected my first post.

      Below is my testcase, it sets up 2 ListGrids (one with datapath set to '/invoice/lineItems' and the other with it set to '/target'). Both ListGrids have saveLocally set to true.

      I've also set canReorderRecords to true and confirmed that this does not trigger an update operation (correct behavior).

      However, if you drag a record from the first to the second then it triggers an update operation (I put an isc.say line in my DataSource to confirm).


      Thank you,

      Code:
      <HTML>
      <HEAD>
      <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta http-equiv="X-UA-Compatible" content="IE=IE8">
      <TITLE>Test Case</TITLE>
      <LINK REL="stylesheet" TYPE="text/css" HREF="">
      <SCRIPT type="text/javascript">var isomorphicDir="/teamworks/script/custom/isomorphic/";</SCRIPT>
      <SCRIPT type="text/javascript" src="script/custom/isomorphic/system/modules/ISC_Core.js"></SCRIPT>
      <SCRIPT type="text/javascript" src="script/custom/isomorphic/system/modules/ISC_Foundation.js"></SCRIPT>
      <SCRIPT type="text/javascript" src="script/custom/isomorphic/system/modules/ISC_Containers.js"></SCRIPT>
      <SCRIPT type="text/javascript" src="script/custom/isomorphic/system/modules/ISC_Grids.js"></SCRIPT>
      <SCRIPT type="text/javascript" src="script/custom/isomorphic/system/modules/ISC_Forms.js"></SCRIPT>
      <SCRIPT type="text/javascript" src="script/custom/isomorphic/system/modules/ISC_DataBinding.js"></SCRIPT>
      <SCRIPT type="text/javascript" src="/teamworks/script/custom/isomorphic/skins/Enterprise/load_skin.js"></SCRIPT>
      </HEAD>
      <BODY>
      <script language="JavaScript">
      isc.defineClass("ISC_WLE").addClassProperties({
      	 localData: {}
      });
      
      isc.defineClass("WLEVariableType", "DataSource").addProperties({
      	clientOnly: true
         ,init: function(args) {
      		this.ID = args.name;
      		this.Super("init", args);
      	}
      });
      
      isc.defineClass("WLEService", "DataSource").addProperties({
          dataFormat: "custom"
         ,operationBindings: [
      		{operationType:"fetch", dataProtocol: 'clientCustom'}
         ]
         ,init: function(args) {
      		this.ID = "WLEService_"+args.name;
      		this.Super("init", args);
      	}
         ,transformRequest: function(dsRequest) {
      		if (dsRequest.operationType == "fetch") {
      			var dsResponse = {
      				clientContext: dsRequest.clientContext
      				,data: new Array(ISC_WLE.localData)
      				,totalRows: 1, startRow: 0, endRow: 1 ,status: 0
      			};
                  this.processResponse( dsRequest.requestId, dsResponse );
      			return;
      		}
      		else {
      			isc.say("WLEService called with operation: " + dsRequest.operationType + " - Why?");
      		}
      	}
      });
      
      function createCanvases() {
      	isc.VLayout.create({
      		ID: "rootsection"
      		,width: 500
      		,height: 500
              ,members: [
              isc.ListGrid.create({
                   height: 200
      			,width: 500
                  ,selectionType: "multiple"
                  ,canSelectRecords: true
                  ,canRemoveRecords: true
      			,valuesManager: "vmLocal"
                  ,dataPath: "/invoice/lineItems"
                  ,canDragRecordsOut:true
      			,canAcceptDroppedRecords:true
      			,dragDataAction:"move" // Works if set to something else
      			,canReorderRecords:true
                  ,selectionAppearance: "checkbox"
      			,saveLocally: true // Save locally set to true
                  ,autoSaveEdits: true
                  ,canEdit: true
                  ,dataFetchMode: "local"
                  ,fields: [
                      { name: "sku", title: "Sku", canEdit: false, showTitle: true}
      			   ,{ canEdit: true, name: "quantity", title: "Quantity", dataPath: "quantity", showTitle: true}
      			   ,{ canEdit: true, name: "taxRate", title: "Tax Rate", dataPath: "taxRate", showTitle: true }
      			   ,{ type: "boolean", canEdit: true, name: "inStock", title: "In Stock", dataPath: "inStock", showTitle: true}
      			   ,{ name: "amount", title: "Amount", canEdit: false,showTitle: true}
      			   ,{ type: "date", canEdit: true, name: "dateArrivedAtWarehouse", title: "Date Arrived At Warehouse:", dataPath: "dateArrivedAtWarehouse",showTitle: true}
      			   ,{ type: "date", canEdit: true, name: "dateShipped", title: "Date Shipped:", dataPath: "dateShipped", showTitle: true}
                  ]
      		})
             ,isc.ListGrid.create({
                   height: 200
      			,width: 500
                  ,selectionType: "multiple"
                  ,canSelectRecords: true
                  ,canRemoveRecords: true
      			,valuesManager: "vmLocal"
                  ,dataPath: "/target"
                  ,canDragRecordsOut:true
      			,canAcceptDroppedRecords:true
      			,dragDataAction:"move" // Works if set to something else
      			,canReorderRecords:true
                  ,selectionAppearance: "checkbox"
      			,saveLocally: true // Save locally set to true
                  ,autoSaveEdits: true
                  ,canEdit: true
                  ,dataFetchMode: "local"
                  ,fields: [
                      { name: "sku", title: "Sku", canEdit: false, showTitle: true}
      			   ,{ canEdit: true, name: "quantity", title: "Quantity", dataPath: "quantity", showTitle: true}
      			   ,{ canEdit: true, name: "taxRate", title: "Tax Rate", dataPath: "taxRate", showTitle: true }
      			   ,{ type: "boolean", canEdit: true, name: "inStock", title: "In Stock", dataPath: "inStock", showTitle: true}
      			   ,{ name: "amount", title: "Amount", canEdit: false,showTitle: true}
      			   ,{ type: "date", canEdit: true, name: "dateArrivedAtWarehouse", title: "Date Arrived At Warehouse:", dataPath: "dateArrivedAtWarehouse",showTitle: true}
      			   ,{ type: "date", canEdit: true, name: "dateShipped", title: "Date Shipped:", dataPath: "dateShipped", showTitle: true}
                  ]
      		})
      		]
          });
      }
      
      Page.setEvent("load", function() {
      	ISC_WLE.localData = {"invoice":{"currency":"GBP","approved":false,"paymentStatus":"Unpaid","customerName":"SomeCo Intl.","lineItems":[{"dateArrivedAtWarehouse":new Date(1307847949922),"inStock":false,"dateShipped":new Date(1307847949922),"amount":93911.12,"taxRate":"19","quantity":1,"sku":"AKO-191"},{"dateArrivedAtWarehouse":new Date(1307847949922),"inStock":false,"dateShipped":new Date(1307847949922),"amount":1592.91,"taxRate":"19","quantity":5,"sku":"ZJQ-139"},{"dateArrivedAtWarehouse":new Date(1307847949922),"inStock":false,"dateShipped":new Date(1307847949922),"amount":232.91,"taxRate":"0","quantity":4,"sku":"ZJQ-277"}],"date":new Date(1307847949922)}};
      	ISC_WLE.localData.zTaskId = "p1";
      	WLEVariableType.create({"fields":[{"type":"text","WLEType":"String","name":"customerName"},{"type":"datetime","WLEType":"Date","name":"date"},{"type":"text","WLEType":"String","name":"paymentStatus"},{"type":"enum","WLEType":"Currency","name":"currency","valueMap":{"EUR":"EUR","NA":"N/A","GBP":"GBP","USD":"USD"}},{"type":"boolean","WLEType":"Boolean","name":"approved"},{"multiple":true,"isComplex":true,"type":"LineItem","name":"lineItems","valueXPath":"lineItems/item"}],"name":"Invoice"});
      	WLEVariableType.create({"fields":[{"type":"text","WLEType":"String","name":"sku"},{"type":"integer","WLEType":"Integer","name":"quantity"},{"type":"enum","WLEType":"TaxRate","name":"taxRate","valueMap":{"0":"Zero Rated","5":"Discounted (5%)","19":"Standard (19%)"}},{"type":"boolean","WLEType":"Boolean","name":"inStock"},{"type":"float","WLEType":"MonetaryAmount","name":"amount"},{"type":"datetime","WLEType":"Date","name":"dateArrivedAtWarehouse"},{"type":"datetime","WLEType":"Date","name":"dateShipped"}],"name":"LineItem"});
      	WLEService.create({"fields":[{"isComplex":true,"type":"Invoice","name":"invoice"},{"multiple":true,"isComplex":true,"type":"LineItem","name":"target","valueXPath":"item"},{"type":"text","name":"zTaskId","primaryKey":true}],"name":"Invoice"});
      	var serviceDS = DataSource.get("WLEService_Invoice");
      	
      	isc.ValuesManager.create({
      		ID: "vmLocal"
      		,dataSource: serviceDS
      	});
      	
      	vmLocal.fetchData();
      	createCanvases();
      });
      </script>
      </BODY>
      </HTML>

      Comment


        #4
        Hello,

        Just wondering if you've had a chance to look at whether this is in fact a bug?

        Thanks,

        Comment


          #5
          We've just made some fixes in this area to ensure that with saveLocally:true, changes triggered by drag and drop are made to local data as well. Can you re-test?

          Comment


            #6
            Hello,

            I've gone and grabbed the latest nightly 2011-06-15-LGPL, emptied my browser cache and ran my testcase.

            I can confirm that update is still called on the DataSource when dragging records between ListGrids where both have saveLocally set to true.

            Comment


              #7
              Hello, I tested also with 2011-06-16 and still face the same issue. Would really appreciate at this point if someone could take a look at the testcase.


              Thank you

              Comment


                #8
                OK, we see the issue and have now fixed it. Thanks for the clear test case.

                Comment

                Working...
                X