Announcement

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

    troubles to fetch and uodate data

    Hi,
    I'm using this code display a ListGrid :
    1- Problem when fetching Data :
    sometimes IE7 display the rights data and sometimes it display a wrong data.
    2- Problem when updating Data :
    when I remove a row from this gridList it works perfect, but when I add a new row, it display the new row and the removed row.
    if I press F5 to refresh the page steel display the old set of data.
    Code:
    function createContainerDataSource()
    {
    	isc.DataSource.create({
    		ID						:	"containerDS",
    		dataFormat		:	"xml",
    		recordXPath		:	"//container",
    		fields				:	[
    		
    			{name:"idMoveTransfert"					, title:"idMoveTransfert "					,primaryKey:"true"},
    			{name:"idCde"										, title:"idCde"											},
    			{name:"idDriver"								, title:"idDriver"									},
    			
    			{name:"idChassis1"							, title:"idChassis1"								},
    			{name:"idChassis2"							, title:"idChassis2"								},
    			{name:"chassisType1"						, title:"Chassis Type"							},
    			{name:"chassisType2"						, title:"Chassis Type"							},
    			{name:"actualSize1"							, title:"Chassis Taille"						},
    			{name:"actualSize2"							, title:"Chassis Taille"						},
    			{name:"sizePlace1"							, title:"size Place"								},
    			{name:"sizePlace2"							, title:"size Place"								},
    			
    			{name:"idContainer1"						, title:"idContainer1"							},
    			{name:"idContainer2"						, title:"idContainer2"							},
    			{name:"etatContainer1"					, title:"etatContainer1"						},
    			{name:"etatContainer2"					, title:"etatContainer2"						},
    			
    			{name:"driverName"							, title:"Driver"										},
    			{name:"chassisNumber1"					, title:"Chassis #1"								},
    			{name:"chassisNumber2"					, title:"Chassis #2"								},
    			{name:"containerNumber1"				, title:"Container #1"							},
    			{name:"containerNumber2"				, title:"Container #2"							},
    			{name:"returnTerminalDate"			, title:"Return Date"								},
    			{name:"pickupTerminalDate"			, title:"Pickup Date"								},
    			{name:"etat"										, title:"etat"											}
    			
    		],
    		
    		operationBindings:[
    			{operationType:"fetch",
    			 dataURL:"<?php echo "../xml/".$_SESSION['userName']."_containers_transfert.xml";?>"
    			 },
    			{operationType:"add",
    			 dataURL:"<?php echo "../xml/".$_SESSION['userName']."_container_transfert_add.xml";?>"
    			 },
    			{operationType:"update",
    			 dataURL:"<?php echo "../xml/".$_SESSION['userName']."_container_transfert_update.xml";?>"
    			 },
    			{operationType:"remove",
    			 dataURL:"<?php echo "../xml/".$_SESSION['userName']."_container_transfert_remove.xml";?>"
    			 }
    		]
    	});			
    }
    function createContainersWindow()
    {
    	isc.Window.create({
    			ID	          			: "containersWindow",
    			title								: "Containers List",
    			autoDraw						: false,
    			canDragResize				: true,
    			showFooter					: false,
    			showHeader					: true,
    			animateMinimize			: true,
    			headerControls 			: ["minimizeButton", "headerLabel", etatSelector],
    			items								: [
    				isc.ListGrid.create	({
    					ID 											: "containersList",
    					typed										: "container",
    					width										:	"100%",
    					height									: "100%",
    					alternateRecordStyles		: true,
    					showAllRecords					: true,
    					showHover								: true,
    					canHover								: true,
    					dataSource							: containerDS,
    					autoFetchData						:	true,
    					fields									: [
    
        				{	name 							: "driverName" ,
        					width							: 150,
    							title 						: "Driver" ,
    							optionDataSource	: driverDS,
    							displayField 			:	"driverName",
    							valueField 				: "idDriver",										
    							autoFetchData			:	true,
    							type							:	"SelectItem"
    		        },
        				{	name 							: "chassisNumber1" ,
        					width							: 150,
    							title 						: "Chassis #1" ,
    							optionDataSource	: chassisDS1,
    							autoFetchData			:	true,
    							displayField 			:	"chassisNumber1",
    							valueField 				: "idChassis1",
    							type							:	"SelectItem",
    							allowEmptyValue 	: true
    
    		        },
        				{ name 							: "chassisNumber2" ,
        					width							: 150,
    							title 						: "Chassis #2" ,
    							optionDataSource	: chassisDS2,
    							displayField 			:	"chassisNumber2",
    							valueField 				: "idChassis2",										
    							autoFetchData			:	true,
    							type							:	"SelectItem",
    							allowEmptyValue 	: true
    		        },					        
    						{name:"containerNumber1"				,width							: 125},
    						{name:"containerNumber2"				,width							: 125},
    						{name:"returnTerminalDate"			,width							: 150},
    						{name:"pickupTerminalDate"			,width							: 150},
    						{name:"etatContainer1"					},
    						{name:"etatContainer2"					},
    						{name:"etat"										, canEdit : false}
    																		],
    					rowEditorExit 					: function (editCompletionEvent, record, newValues, rowNum)
    					{
    						containersList.saveAllEdits();
    						if(editCompletionEvent == 'enter'  || editCompletionEvent == 'tab'|| editCompletionEvent == 'click_outside')
    						{
    							
    							saveMoveModifications(newValues, record) ;
    						}
    					},
    					canResizeFields				: true,
    					canReorderRecords			: false,
    					getBaseStyle					: function (record, rowNum, colNum) 
    					{
    						if(record != null)
    						{
    							if(record.etat == 'DED')
    								return "myHighGridCell";
    							else
    								return "myLowGridCell";
    						}
    					},
    					cellContextClick				:	"return containerMenu.showContextMenu()",
    					canEdit									: true,
    					editEvent								: "click",
    					endEditing							: function () { containersList.saveAllEdits(); },
    					modalEditing						: true
    				})
    			]
    	});		
    }
    the xml file to fetch data : _containers_transfert.xml

    Code:
    <response>
    <status>1</status>
    <data>
    <container>
    <idMoveTransfert>11</idMoveTransfert>
    <idCde>2</idCde>
    <idDriver>1</idDriver>
    <idChassis1>3</idChassis1>
    <idChassis2>1</idChassis2>
    <chassisType1>40 Combo</chassisType1>
    <chassisType2>20</chassisType2>
    <actualSize1>40</actualSize1>
    <actualSize2>20</actualSize2>
    <sizePlace1>2</sizePlace1>
    <sizePlace2>1</sizePlace2>
    <idContainer1>3</idContainer1>
    <idContainer2>4</idContainer2>
    <etatContainer1>DED</etatContainer1>
    <etatContainer2>DED</etatContainer2>
    <driverName>YVON.DRAGMEERE</driverName>
    <chassisNumber1>11113(40 Combo)</chassisNumber1>
    <chassisNumber2>11110(20)</chassisNumber2>
    <containerNumber1>AAAAAA</containerNumber1>
    <containerNumber2>BBBBBB</containerNumber2>
    <returnTerminalDate>0000-00-00 00:00:00</returnTerminalDate>
    <pickupTerminalDate>0000-00-00 00:00:00</pickupTerminalDate>
    <etat>DED</etat>
    </container>
    <container>
    <idMoveTransfert>18</idMoveTransfert>
    <idCde>2</idCde>
    <idDriver></idDriver>
    <idChassis1></idChassis1>
    <idChassis2></idChassis2>
    <chassisType1></chassisType1>
    <chassisType2></chassisType2>
    <actualSize1></actualSize1>
    <actualSize2></actualSize2>
    <sizePlace1></sizePlace1>
    <sizePlace2></sizePlace2>
    <idContainer1>17</idContainer1>
    <idContainer2>18</idContainer2>
    <etatContainer1>PED</etatContainer1>
    <etatContainer2>PED</etatContainer2>
    <driverName></driverName>
    <chassisNumber1></chassisNumber1>
    <chassisNumber2></chassisNumber2>
    <containerNumber1>CCCCC</containerNumber1>
    <containerNumber2>DDDDD</containerNumber2>
    <returnTerminalDate>0000-00-00 00:00:00</returnTerminalDate>
    <pickupTerminalDate>0000-00-00 00:00:00</pickupTerminalDate>
    <etat>RTR</etat>
    </container>
    <container>
    <idMoveTransfert>26</idMoveTransfert>
    <idCde>2</idCde>
    <idDriver></idDriver>
    <idChassis1></idChassis1>
    <idChassis2></idChassis2>
    <chassisType1></chassisType1>
    <chassisType2></chassisType2>
    <actualSize1></actualSize1>
    <actualSize2></actualSize2>
    <sizePlace1></sizePlace1>
    <sizePlace2></sizePlace2>
    <idContainer1>13</idContainer1>
    <idContainer2></idContainer2>
    <etatContainer1>PED</etatContainer1>
    <etatContainer2></etatContainer2>
    <driverName></driverName>
    <chassisNumber1></chassisNumber1>
    <chassisNumber2></chassisNumber2>
    <containerNumber1>EEEEE</containerNumber1>
    <containerNumber2></containerNumber2>
    <returnTerminalDate>0000-00-00 00:00:00</returnTerminalDate>
    <pickupTerminalDate>0000-00-00 00:00:00</pickupTerminalDate>
    <etat>RTR</etat>
    </container>
    </data></response>
    The xml file to update data

    Code:
    <response>
    <status>1</status>
    <data>
    <container>
    <idMoveTransfert>30</idMoveTransfert>
    <idCde>2</idCde>
    <idDriver></idDriver>
    <idChassis1></idChassis1>
    <idChassis2></idChassis2>
    <chassisType1></chassisType1>
    <chassisType2></chassisType2>
    <actualSize1></actualSize1>
    <actualSize2></actualSize2>
    <sizePlace1></sizePlace1>
    <sizePlace2></sizePlace2>
    <idContainer1>13</idContainer1>
    <idContainer2></idContainer2>
    <etatContainer1>PED</etatContainer1>
    <etatContainer2></etatContainer2>
    <driverName></driverName>
    <chassisNumber1></chassisNumber1>
    <chassisNumber2></chassisNumber2>
    <containerNumber1>KKKKKK</containerNumber1>
    <containerNumber2></containerNumber2>
    <returnTerminalDate>0000-00-00 00:00:00</returnTerminalDate>
    <pickupTerminalDate>0000-00-00 00:00:00</pickupTerminalDate>
    <etat>RTR</etat>
    </container>
    </data></response>
    this functions are invoked after the generation for the new xml Files

    Code:
    function responseSaveMoveModifications(update)
    {
    	if((update == 1)||(update == 12)||(update == 2))
    	{
    		containersList.updateData({});
    	}
    	if(update == 0)
    	{
    		alert('Vous avez dépassé le nombre total de containers');
    	}								
    	isc.clearPrompt();
    }			
    
    function responseEditNewMove(update)
    {
    	if(update == 1)
    	{
    		containersList.addData({});
    	}
    	isc.clearPrompt() ;
    }
    
    function responseDeleteMoveTransfert(update)
    {
    	if(update == 1)
    	{
    		containersList.removeData({});
    	}
    	isc.clearPrompt() ;
    }
    Thank You

    #2
    1 & 2) your XML files are possibly cacheable so you are getting old responses. Set them not cacheable using standard HTTP headers (eg Cache-Control: no-cache)

    2) duplicate row: make sure the primary key matches between the add request and response and enable the ResultSet log category in the Developer Console to see diagnostic output about updating the cache.

    Your functions at the end of your code don't seem to make any sense. The updateData() call is invalid with no data (it needs at least a primary key value or it's not clear what record is being updated) and your addData() call would at best add a new, blank record. These strange calls are likely to be part of the problem you're having. Please read the docs for these methods you're calling first.

    Comment


      #3
      Still some troubles

      Hi,
      thank you for your quick response,
      I already used this line of Code : header( 'Cache-Control: no-store, no-cache, must-revalidate' );
      but I have the same problems.
      I try to invoke updateData with the primary key and there is no changement.
      if there is any solutions please let me know,
      --Thank You

      Comment


        #4
        The solution is to fix your code.. please follow the rest of the tips and advice you were already given before asking for more help.

        Comment

        Working...
        X