Dataset property not working.

Forum to discuss the new web client version of Servoy.

Dataset property not working.

Postby ashutoslenka426 » Sat May 20, 2017 8:00 am

Hi All ,

I am trying to develop a pivot grid webcomponent . It needs all the records from the db . So I am trying to assign a dataset fetching all the records . But in the spec file the dataset property is not working .

Code: Select all
"jsDataSet":{"type" :"dataset", "includeColumnNames": true,
                                 "columnTypes":{ "icon" : "media" }}


jsDataset property is not showing in the properties ??.

But it is working when assigning a foundset . but foundset is fetching only the 200 records . How can we get all the records in the foundset ? .

The servoy version is 8.1.2.

Please provide some suggestion.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Dataset property not working.

Postby ashutoslenka426 » Mon May 22, 2017 1:48 pm

Please provide some suggestions on this.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Dataset property not working.

Postby patrick » Mon May 22, 2017 2:01 pm

Since a dataset can only be created at runtime, a property doesn't make much sense. Create an API call that sends the dataset (e.g. elements.x.showPivot(dataset)).
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Dataset property not working.

Postby patrick » Mon May 22, 2017 2:02 pm

btw: we have just demonstrated a pivot component at ServoyWorld that will be made available soon. Maybe you want to wait for that...
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Dataset property not working.

Postby ashutoslenka426 » Mon May 22, 2017 2:27 pm

Hi Patrick ,

Thanks for your reply . Do we need angular services for this ? . Can you please be elaborate . How we can achieve this ?
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Dataset property not working.

Postby patrick » Mon May 22, 2017 2:38 pm

No. In your spec file add an "api" property, as for example

Code: Select all
...,
"model":
{
   ...
},
"api":
{
   "pivot": {
      "parameters": [
         { "name": "dataset", "type": {"type": "dataset", "includeColumnNames": "true" } }
      ]
}
...


And implement that method in your js file as for example

Code: Select all
$scope.api.pivot = function(dataset) {
   ...
}


Make sure "api" is mapped in your js file as in

Code: Select all
scope: {
   model: '=svyModel',
   api: "=svyApi"
}

Everything is pretty nicely explained in the docs here: https://wiki.servoy.com/pages/viewpage. ... Id=1869552
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Dataset property not working.

Postby Andrei Costescu » Mon May 22, 2017 3:54 pm

Just a side note (answering your q. on top about how a foundset could be used).

If you want to use a foundset property type this page describes what you get in the browser and how to use that: https://wiki.servoy.com/display/public/ ... perty+type
You can use $scope.model.myFoundsetProperty.loadRecordsAsync(...) or $scope.model.myFoundsetProperty.loadExtraRecordsAsync(...) to load more records in the viewport.
You can also play with the settings described in "Defining initial load options for a foundset property" section in spec. Like set a very large value for "initialPreferredViewPortSize".

The foundset on server behaves as any foundset behaves - loads only first 200 records initially on server. If you get/read the last loaded record it will load more records on server if available.
If you want to load all the records on server I guess you can use a combination of databaseManager.getFoundSetCount(...) and foundset.getRecord(lastRecordIndex) to really load everything.

But using datasets might be easier for what you try to accomplish, if you are not interested in showing dynamic data (so just a static set of data).
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: Dataset property not working.

Postby ashutoslenka426 » Tue May 23, 2017 12:13 pm

Thanks . I am sending the dataset from the server side to the client side using the api . But the format which my devex pivot grid will accept is :

Code: Select all
var sales = [{
    "id": 1,
    "region": "North America",
    "country": "USA",
    "city": "New York",
    "amount": 1740,
    "date": "2013/01/06"
}, {
    "id": 2,
    "region": "North America",
    "country": "USA",
    "city": "Los Angeles",
    "amount": 850,
    "date": "2013/01/13"
}, {


So what I am doing is , in the servoy side I am pogramatically preparing data and sending to the client side using api . I am recieving it fine but not rendering correctly ???.

But this is rendering fine

Code: Select all
$scope.mode.foundset.viewPort.rows


How to achieve data in this format ? .

Please provide some suggestions on this.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Dataset property not working.

Postby patrick » Tue May 23, 2017 12:24 pm

So you say in the client you are getting the data the way the component wants it, but it doesn't render right? Or do you just get the dataset in the client and simply provide that the component?
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Dataset property not working.

Postby ashutoslenka426 » Tue May 23, 2017 1:34 pm

Thanks Patrick for your reply . Something is going wrong . The component wants data in a very complex mode . Can we achieve this ?
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Dataset property not working.

Postby patrick » Tue May 23, 2017 3:08 pm

Did I mention that we are about to publish something like this in a week or so :wink:? For that component, I had to do just that. Here is a code snippet:

Code: Select all
var columnNames = dataset.shift(); //assumes the column names are in the dataset as first row
var data = []; //data array for the component's data
for (var i = 0; i < dataset.length; i++) { //loop over dataset
   var dataObj = { }; //create an object for record i
   for (var c = 0; c < columnNames.length; c++) { //go over all column names
      dataObj[columnNames[c]] = dataset[i][c]; //create a property in dataObj with the column name and set value
   }
   data.push(dataObj); //add dataObj to data array
}


That gives you the data in this kind of "format" (you might have to deal with dates a bit more):

Code: Select all
var sales = [{
    "id": 1,
    "region": "North America",
    "country": "USA",
    "city": "New York",
    "amount": 1740,
    "date": "2013/01/06"
}, ...]
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Dataset property not working.

Postby ashutoslenka426 » Wed May 24, 2017 1:35 pm

Thanks Patrick for your reply. Now I am sending the dataset in the right format to the js . But could not able to bind with the component .What I noticed is api call is creating problem .How can I deal correctly with the api call ? . Please provide your suggestions .
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Dataset property not working.

Postby patrick » Wed May 24, 2017 2:13 pm

It is really a bit hard to help you with this over the forum. Building a rather complex component like a Pivot grid requires quite a bit of understanding of the technology involved.

What should I answer to "api call is creating problem"? What problem is it creating? Dou you get your dataset in the client? Have you tried to convert the data to the format your component wants as I suggested? I just can't tell where you are stuck from the bits you give me...
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Dataset property not working.

Postby ashutoslenka426 » Wed May 24, 2017 2:19 pm

Thanks . Yes I got the dataset in the client . Yes I converted the data to the format my component wants .

But still grid is not populating it . Then I tried to show a static data . Still it was not showing . I removed the api function . Then it showed me the static data .

Please provide your suggestions.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Dataset property not working.

Postby patrick » Wed May 24, 2017 2:27 pm

That sounds a bit like your component did already render and you miss the point on how to re-populate it with new data. So static data initially available shows, but when you try to repopulate your grid, it does not work. Then you really have to look at the documentation of that component...
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Next

Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 5 guests