dataprovider not getting updated

Hi All ,

I have created a combobox using Devex . I am not using the default combobox . I have assigned a valuelist to it . I have assigned a dataprovider to it . It is a form variable . When I am changing the combobox , it is not updating the dataprovder . It is not changing the form variable . What I need to do in js to update it ? . Please help me . Please provide some suggestion .

See https://wiki.servoy.com/pages/releasevi … Id=1869552
Combo box .spec file must use pushToServer allow or higher to allow dataprovider value to be changed on server. You can find info about that on that wiki page.

Then in order for the client to push changes to server you have to use either “svy-autoapply” directive it that works with your component or otherwise you need to use the “svyServoyapi.apply” call.
See https://wiki.servoy.com/pages/releasevi … Id=8061131 for more details about that.

Hi Andrie ,

I have done that already but still not successful

  return {
      restrict: 'E',
      scope: {
    	  model: '=svyModel',
		  handlers: "=svyHandlers",
		  api: "=svyApi",
		  svyServoyapi: "="	  
      },
      controller: function($scope, $element, $attrs,$window) {
    	  if($scope.model.Valuelist!=undefined&&$scope.model.dataproviderID!=undefined){
    		  $scope.value=$scope.model.Valuelist[$scope.model.dataproviderID].realValue;
    	 }
    
    	  $scope.selectBox = { 
		        dataSourceUsage: {
		            dataSource: new DevExpress.data.ArrayStore({ 
		                data: $scope.model.Valuelist,
		                key: "realValue"
		            }),
		            displayExpr: "displayValue",
		            valueExpr: "realValue",
		            hint:$scope.model.hint,
					value:$scope.value,
					validationMessageMode:"always",
    	            validationError:{type:'required',message:$scope.model.validationMessage},
					onFocusOut:function(event){
						$scope.handlers.onFocusLostMethodID($scope.value || "no value");
					},
					onFocusIn:function(event){
						$scope.handlers.onFocusGainedMethodID($scope.value || "no value")
					},
     	            onValueChanged:function(company_id){
     	            	//if($scope.handlers.onActionMethodID!=undefined){
     	            		 $scope.value = company_id.value;
     	            		 $scope.handlers.onActionMethodID(company_id.value);
     	            		 $scope.svyServoyapi.apply('dataProviderID');
     	            	//}
			        },	
			            bindingOptions: {
				        	disabled: '!model.enabled',
							 isValid: 'model.isValid',
							 rtlEnabled: 'model.rtlEnabled',
				        }
		        }	 	
		};
   "size": { "type" :"dimension",  "default" : {"width": 140, "height": 35} },
	      	"dataproviderID" : { "type":"dataprovider", "pushToServer": "allow","tags": { "scope" :"design" }, "ondatachange": { "onchange":"onValueChanged", "callback":"onDataChangeCallback"}},
	      "enabled" : { "type": "enabled", "blockingOn": false, "default": true, "for": ["dataProviderID","onValueChanged","onKeyPressMethodID"] },
	        "styleClass" : { "type" :"styleclass", "tags": { "scope" :"design" }},   		
	        "visible" : "visible",
	     	"Valuelist":{"type":"valuelist", "tags": { "scope" :"design" },"pushToServer":"allow",

Please providse your help and suggestion.

Hi, have you tried already to inspect the browser and debug your clientside code (using the browser inspector) ?
You should make sure that the $scope.svyServoyapi.apply(‘dataProviderID’); is executed in first place.

Anyhow i see a typo in your spec/js file. You apply the change to the model property “dataProviderID” but in your .spec file the property name is “dataproviderID”. This is why the change is not pushed to the server. Note also that you will get an error in browser console if the element doesn’t have an onAction method id.

onValueChanged:function(company_id){
//if($scope.handlers.onActionMethodID!=undefined){
$scope.value = company_id.value;
$scope.handlers.onActionMethodID(company_id.value);
$scope.svyServoyapi.apply(‘dataProviderID’);
//}
}

This function can be written like this

onValueChanged:function(company_id){
$scope.value = company_id.value; //
$scope.svyServoyapi.apply(‘dataproviderID’); // i suggest to rename the property in .spec file to ‘dataProviderID’ to keep it consistent with all other components

// check if there is an handler, if yes execute the handler.
if ($scope.handlers.onActionMethodID){
$scope.handlers.onActionMethodID(company_id.value);
}
}

Regards,
Paolo

Thanks Paolo it’s working now.

Hi ,

That issue is fixed . But I am getting another console exception when trying to add the valuelist to the combobox . Although the functioanlityis working fine .

Valuelist: article_XXXX used with different types
The valuelist was already created for type: INTEGER
 for the dataproviders: Milan
So it can't be used also for type: TEXT for the dataprovider: null
Please edit these dataprovider(s) (using table editor for database column or Edit variable context menu action for variables) of this valuelist: article_XXXX so that they have the same type.

How do you add the valeuelist? From properties view?

article_XXXX is probably a custom valuelist that was used in one place for a dataprovider of type INTEGER.
Then you add it to your component where the valuelist doesn’t know know it’s for a dataprovider → and tries to default to type TEXT. This is why the error message appears.
Try “Valuelist”:{“type”:“valuelist”, “tags”: { “scope” :“design” }, “for”: “dataproviderID”(…)

And then if your dataproviderID is INTEGER as well you shouldn’t get that message.
Btw you don’t have to name it “dataproviderID”, you can choose anything (that is like that due to legacy constraints for default components).

Hi ,
My code is already fine I think .

	"size": { "type" :"dimension",  "default" : {"width": 140, "height": 35} },
	      	"dataproviderID" : { "type":"dataprovider", "pushToServer": "allow","tags": { "scope" :"design" }, "ondatachange": { "onchange":"onValueChanged", "callback":"onDataChangeCallback"}},
	      	"enabled" : { "type": "enabled", "blockingOn": false, "default": true, "for": ["dataProviderID","onValueChanged","onKeyPressMethodID"] },
	        "styleClass" : { "type" :"styleclass", "tags": { "scope" :"design" }},   		
	        "visible" : "visible",
	     	"Valuelist":{"type":"valuelist", "tags": { "scope" :"design" },"pushToServer":"allow","dynamicDataproviders":true,"provideColumnFormats":true, "for": ["dataproviderID","onActionMethodID","onDataChangeMethodID"]},

Please provide your suggestion.

When does it happen?
What type is the dataprovider you set on it?

Thanks for your reply .

This happens when I try to assign the valuelist to the combobox.

I have set it to Integer type of data.

Please provide your suggestion.

ashutoslenka426:
This happens when I try to assign the valuelist to the combobox.

How exactly do you try to assign? From the properties view? From javascript (at runtime)?

From the properties view.

It says “So it can’t be used also for type: TEXT for the dataprovider: null”
So it doesn’t find the dataprovider value set in dataproviderID.

You set lots of things in the spec that are not supported on the valuelist type.
Try with just “Valuelist”:{“type”:“valuelist”, “tags”: { “scope” :“design” },“for”: “dataproviderID” }.

dynamicDataproviders and provideColumnFormats are only meant for foundset property types, “for” in valuelist properties types should point directly to a dataprovider typed property, so not an array that also contains handler names.

Thanks for your reply . But still not working.

I would like to explain the exact scenario . I have developed the dropdown web component for devex . when I am placing only the dropdown web component , it is not showing any exception .

When I am placing both the dropdown component as well as the default servoy dropdown , it is throwing the exception .

http://forum.servoy.com/viewtopic.php?f=22&t=21016 . Please refer this

Please provide some suggestion.

The only thing that I can say is to make sure the dataproviders of both your dropdown component as well as the default servoy dropdown that uses the same valuelist should be exactly the same type.
So not one DP is text and the other one integer.

If you already made sure that is the case, then it needs further investigation. You should create a case with a sample solution showing this problem then.