dataprovider not getting updated

Forum to discuss the new web client version of Servoy.

dataprovider not getting updated

Postby ashutoslenka426 » Wed May 17, 2017 11:18 am

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 .
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: dataprovider not getting updated

Postby Andrei Costescu » Wed May 17, 2017 12:01 pm

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.
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: dataprovider not getting updated

Postby ashutoslenka426 » Wed May 17, 2017 12:24 pm

Hi Andrie ,

I have done that already but still not successful
Code: Select all
  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',
                    }
              }       
      };   


Code: Select all
   "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.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: dataprovider not getting updated

Postby paronne » Wed May 17, 2017 1:18 pm

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
paronne
 
Posts: 203
Joined: Fri Nov 02, 2012 3:21 pm

Re: dataprovider not getting updated

Postby ashutoslenka426 » Wed May 17, 2017 1:26 pm

Thanks Paolo it's working now.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: dataprovider not getting updated

Postby ashutoslenka426 » Wed May 17, 2017 2:06 pm

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 .

Code: Select all
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.

AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: dataprovider not getting updated

Postby Andrei Costescu » Wed May 17, 2017 2:55 pm

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).
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: dataprovider not getting updated

Postby ashutoslenka426 » Wed May 17, 2017 3:25 pm

Hi ,
My code is already fine I think .

Code: Select all
   "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.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: dataprovider not getting updated

Postby Andrei Costescu » Wed May 17, 2017 3:36 pm

When does it happen?
What type is the dataprovider you set on it?
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: dataprovider not getting updated

Postby ashutoslenka426 » Wed May 17, 2017 3:38 pm

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.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: dataprovider not getting updated

Postby Andrei Costescu » Wed May 17, 2017 4:03 pm

ashutoslenka426 wrote: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)?
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: dataprovider not getting updated

Postby ashutoslenka426 » Wed May 17, 2017 4:06 pm

From the properties view.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: dataprovider not getting updated

Postby Andrei Costescu » Wed May 17, 2017 4:50 pm

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.
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: dataprovider not getting updated

Postby ashutoslenka426 » Thu May 18, 2017 6:03 am

Thanks for your reply . But still not working.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: dataprovider not getting updated

Postby ashutoslenka426 » Thu May 18, 2017 8:04 am

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.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Next

Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 24 guests

cron