Hi,
is there an easy or recommended way to define initial sorting for the data grids.
By default the records are sorted by the value of the primary index.
In many cases this isn't useful.
Thanks in advance.
Wolfgang
Hi Edsel,
to make it work I changed the statement to
$scope.model.gridOptions.dataSource.sort = function() {
return {field: "LastName", dir: "asc"};
thanks
Wolfgang
Hello Wolfgang,
By default the records are sorted by the value of the primary index of the temp-table.
If wanted, you could change the primary index of the temp-table in the Business Entity. It does not have to be the same as the index in your actual database table.
In Kendo UI Builder you can specify a default sorting for the data source by overriding the sort configuration property.
For a pre-defined template, you can override the sort property in the onShow() function in the <project>/src/scripts/<view-name>/view-factory.js file.
Example:
onShow: function($scope, customData) {
this.scope = $scope;
$scope.customerDg.options.dataSource.sort = {field: "CustNum", dir: "desc"};
}
Note: customerDg is the name of view.
For a view created using the Blank view option in KUIB 1.1, the syntax is a bit different.
Please let me know if you are using KUIB 1.1.
I hope this helps,
Edsel
Hello Edsel,
thanks for your hints. Changing the primary index in the temp-table works fine for client-side processing, with serverside paging it only sorts the results of each page returned bs the server.
This will probably happen with sorting onShow. I tried sorting onShow as described by you, but I always get the error
angular.js:13424 TypeError: Cannot read property 'options' of undefined
at LandOrtsliste.onShow (view-factory.js:22)
My app's name is Land and the view is called Ortsliste
I tried $scope.Ortsliste.options.dataSource.sort={field: "obez"}; and
$scope.LandOrtsliste.options.dataSource.sort={field: "obez"};
I get the same error
To get the right sorting with serverside pagind, it is necessary to add a "use-index" or "by" clause to the query-statement.
There is a capability "orderBy" in the business entity for serverside paging
@openapi.openedge.method.property (name="mappingType", value="JFP").
@openapi.openedge.method.property (name="capabilities", value="ablFilter,top,skip,id,orderBy").
So the question is, how to define an initial value for the orderBy-value.
best regards
Wolfgang
Hello Wolfgang,
If you are using Kendo UI Builder 1.0, please check that Ortsliste is in lowercase:
$scope.Ortsliste.options.dataSource.sort={field: "obez"};
If you are using kendo UI Builder 1.1, your code would need to look like the following:
onShow: function($scope, customData) {
this.scope = $scope;
$scope.model.options.dataSource.sort = function() {
return {field: "CustNum", dir: "desc"};
}
},
You can use the JavaScript Debugger to query the properties of $scope.
By default the sort option is processed on the client side.
You can unckeck the "Client-side Processing" option in the Edit Data Source dialog to enable the server-side processing: server paging, server filtering and server sorting.
The sort expression (orderBy) is sent to the server with server-side processing enabled.
I believe that you have already enabled the JFP in your Business Entity following the sample shown in the documentation:
documentation.progress.com/.../index.html
It is important to highlight that the server-side sorting is implemented by using a "seq" field in the temp-table definition.
DEFINE TEMP-TABLE ttCustomer BEFORE-TABLE bttCustomer
...
FIELD seq AS INTEGER INITIAL ?
...
INDEX seq IS PRIMARY UNIQUE seq
....
The seq field is set when resolving the query with the sorting.
The result is then returned using the order of the primary index which corresponds to the specified sorting.
This also enables sorting the grid dynamically when using the "Enable Sorting" option.
Please try these suggestions and let me know how it goes.
Cheers,
Edsel
Hello Edsel,
I am using the Kendo UI Builder 1.0.
The view is named Ortsliste in the KUIB but
$scope.Ortsliste.options.dataSource.sort={field: "obez"}; throws the reference error.
$scope.ortsliste.options.dataSource.sort={field: "obez"}; doesn't throw an it works fine for clientside processing - not for serverside paging, but that is ok.
So there is a difference between the name of a view as it is defined and the internal KUIB use.
In an other example the view-name is "Land-List" and $scope.landList.options.dataSource.sort={field: "ldplz", dir: "asc"}; is working. This I found out by trial and error.
Defining an other view which is a copy of "Ortsliste" with name "Ortex" I get the reference error again. How can I find out the internal name of the view? Is it a bug fixed in Version 1.1?
thanks & cheers
Wolfgang
Hello Wolfgang,
>> $scope.ortsliste.options.dataSource.sort={field: "obez"}; doesn't throw an it works fine for clientside processing - not for >> serverside paging, but that is ok.
To understand why serverside paging is not working, you would need to look at the payload that is sent to the server and the response to see if they expected.
I believe that you should be able to use "ortex". The generation in version 1.0 uses camel case and removes hyphens.
I generally, look at the object with the debugger to find out the name.
In Kendo UI Builder in version 1.1 uses "model" instead of the name of the view.
I hope this helps,
Edsel
One more thing regarding Kendo UI Builder version 1.1.
For views created using the Blank view option, you would define datasources to use in the view and access the datasource and the model programmatically by using:
$scope._$ds["<data-source-name>"]
$scope._$viewModels["<model-name>"]
If the data-source-name is something like "CustomerDS", the model name would be "CustomerDSModel".
Thanks.
Hi Edsel,
following your hints I got the sort I wished with KUIB 1.0 for both client and server side processing.
Now with KUIB 1.1. I followed your advice and defined:
/* "customData" is the data return by the viewInitHandler handler*/
onShow: function($scope, customData) {
this.scope = $scope;
$scope.model.options.dataSource.sort = function() {
return {field: "LastName", dir: "asc"};
}
},
an now I get the console message
TypeError: Cannot read property 'dataSource' of undefined
at OrderEntryEmployee.onShow (view-factory.js:23)
Is there any documentation for KUIB 1.1 for how to set sort and ablfiler for the onShow event?
thanks in advance
kind regards
Wolfgang
Hi Edsel,
to make it work I changed the statement to
$scope.model.gridOptions.dataSource.sort = function() {
return {field: "LastName", dir: "asc"};
thanks
Wolfgang